I have configured a bucket and to access the files uploaded here what should be the Yaml handler statement?
For example: http://commondatastorage.googleapis.com/yii2assets/e896c38e/css/bootstrap.css
When I browse this CSS file it prompts to download and looks it doesn’t understand the MIME type.
I can’t provide a static directory since it’s hosted on Google Storage and to access I need to use the URL mentioned above.
Please let me if you have any IDEAS.
What I need is a handle like:
url: bootstrap.css
script : URL FROM where TO SERVER
Like if I have to use a JQuery CDN URL.
You can upload static file with your code then config Yaml with static_files please see in doc.
If you want to upload file to Google Storage you can access by sending parameter from python to html file. It depend how you implement it Java, Python have a difference way to implement this.
Related
I'm using "github.com/dgrijalva/jwt-go" to create JSON web tokens.
When I hosted my server locally, I could use my private key as usual. But in GAE it won't work because I don't have access to the file system.
How would you guys do it? Store the key in datastore or any other ideas?
Thanks
Edit:
My app.yaml looks like this (below api_version and stuff):
handlers:
- url: /.*
script: _go_app
On AppEngine you don't have access to the file system of the host operating system, but you can access files of your web application (you have read-only permission, you can't change them and you can't create new files in the app's folder).
So the question is: do you want to change this private key from your application without redeploying your app? Or it is perfectly fine if it is deployed "statically" with your app's code?
If you don't need to change it (or only when you redeploy your app), easiest is to store it as a "static" file as part of your webapp. You may refer to files of your app using relative paths, where the current or working directory is your app's root. E.g. if your app contains a key folder in its root (where app.yaml resides), and there is a my_key.txt file inside the key folder, you can refer to it with the path: key/my_key.txt.
Actually it is quite common to "ship" static files with your app's code: just think of HTML templates which are read and processed by the Go code (e.g. package html/template) to produce HTML result; the content of the HTML template files are not served directly to clients.
If you need to change it from time to time without having to redeploy your app, then store it in the Datastore which your app can read and modify.
Note:
One important note: not every file is readable by code, this depends on the app configuration. Quoting from Configuring with app.yaml / Static file handlers:
Static files are files to be served directly to the user for a given URL, such as images, CSS stylesheets, or JavaScript source files. Static file handlers describe which files in the application directory are static files, and which URLs serve them.
For efficiency, App Engine stores and serves static files separately from application files. Static files are not available in the application's file system. If you have data files that need to be read by the application code, the data files must be application files, and must not be matched by a static file pattern.
Static file handlers can be defined in two ways: as a directory structure of static files that maps to a URL path, or as a pattern that maps URLs to specific files.
Read the link how to properly configure application and static files / directories.
The solution was to leave app.yaml as it were. Put app.yaml at root lvl in project. Then change all imports from starting at GOPATH to start at project root instead. The problem that made me choose to put app.yaml and main go file in a different folder under project root was because of double imports. Read this for a better understanding: Google Go AppEngine imports and conflicts when serving / testing
The solution made my project find the files I wanted.
I am using ng-file-upload library to post files to my back end Web Api. Once the file is posted I save it to the following folder
"~/App_Data/Tmp/FileUploads/"
and also save the path to my database.
Now when I go on edit mode; I want to get a preview of all uploaded files (photos). But when I use something like
ng-src="path"
I get
"Not allowed to load local resource"
is this the right approach, when serving files from disk?
That path is a server path and not a client path so for sure that won't work.
You need to have an endpoint on your server to allow downloading those files with id or name/path and then set the src of the img to that url.
The implementation download endpoint depends on your backend technology.
If in your edit mode you still have access to the file object that use has just selected then you can do:
<img ngf-src="file">
I have a rest app with resteasy, which creates files and stores them and return the path, so I can see the name in the screen. The problem: When I want to download the file, I create the url with "app url" + "file path" but that doesn't work. The message is:
Could not find resource for relative : /publications_report_486.doc of full path:
http://127.0.0.1:8080/SIISA-Rest-0.6/publications_report_486.doc
In this example, I store the file in the app's root, so I just have to add the filename to the url.
I think resteasy is trying to find that url within their resources(services) and it doesn't find the path, so it doesn't access to the file, it just search the services.
How could I fix this?
I'm not sure how to return the file from within Resteasy - I've been looking for that myself which is how I stumbled across this, but you could probably deal with this particular problem by tweaking the your web.xml so that it doesn't include the location where you store your files in the servlet-mapping to Resteasy. You may want to have a look at the approach in this answer.
What I'm trying to do is simple. Load am XML file using ElementTree so I can traverse it.
Here's the code:
_uri = '/news.xml'
self.root = ElementTree.parse(_uri).getroot()
And, the error:
file not accessible: '/news.xml'
From what I can tell, the parser can't find the document. Is there something I need to configure so python can see my site's files?
This is probably similar to:
Read a file on App Engine with Python?
I.e. files that are marked as static are not accessible, but you can also serve it as an application resource file.
I dont want a config file only for cherrypy. I need it only for a very smallish webserver which wont be actually accesible to the world, so no need for me to mock around in config files.
Is there a way to pass a "config" to wsgiserver when starting it? I just need a 5-10 line script to fire of a threading web server, which can run a flask application and server static files.
Also, I dont want to specify full path to the static files, just ./static from where the script is ran.
According to Changing default url to static-media in Flask the only option is to map /static to something that serves from os.getcwd() + '/static'.
Or with CherryPy: How to use cherrypy as a web server for static files?