I have developed an app using Flask and App Engine. I was able to upload file in google cloud storage, but not able to delete file.
I am using: files.delete('/gs/bucket/file.pdf') to delete a file.
App executes this line, but file is not deleted from cloud storage.
According to https://developers.google.com/appengine/docs/python/googlestorage/functions#delete, it should work.
It is not even working in local development server also.
Please let me know, what I am missing or is there any better to achieve this?
Related
Is Google cloud Engine App filesystem ephemerial such as heroku (this link is another stackoverflow question that explains how the ephemerial filesystem works) ?
l would like to deploy a python-django project there and to know if I could use the built-in django database file.
Heroku’s filesystem is both ephemeral and dyno-local, for e.g. if you try to view a saved file via heroku run bash you won't see it (that runs on a one-off dyno, not a running web dyno) and it will be lost within 24 hours due to automatic dyno restarts. You just need a database Heroku has a PostgreSQL service with a free tier that should do more than you need, or pick another data persistence addon.
Coming to App Engine,
App Engine Flexible (Managed VMs), is ephemeral (disk initialized on each VM startup). It scales across many containers so there's no promise that a file you write to one will be accessible later. You
can get away with dealing with some writing to some /tmp files
but not much more. You will be much better off writing any data to something like Cloud Datastore, Cloud SQL, Memcache, or
Cloud Storage.
The App Engine Standard filesystem is not ephemeral but it is
read-only. You cannot write to the filesystem. Python 2.7 and PHP 5.5 don't have write access to the disk whereas Java 8, Java 11, Node.js,Python 3, PHP 7, Ruby, Go 1.11, and Go 1.12+ only have read and write access to the /tmp directory.
You could use Google App Engine Blobstore or BlobProperty in
Datastore to store blobs/files. For using Blobstore (up to 2GB) see
this For using Datastore blobs (only up to 1MB) see this
I have a Django application running on google app engine. Just because I don't know how to use Git, I usually download latest app engine version from google cloud build and work with different folder names. However this last week, when I try to download my google app engine project, I get this following error:
No such object: staging.project-id.appspot.com/eu.gcr.io/project-id/appengine/default.datetime:latest
I know I can get my files from cloud shell but I couldn't do it. Thats how I have found cloud builds after searching it for like a week.
Note: My Django app is still running.
A Cloud Storage bucket named staging.project-id.appspot.com was deleted or missing.
The Cloud Build files are stored in a Cloud Storage to serve as staging before being deployed to App Engine. You can try redeployment to re-create the said bucket.
Here's another option to download your App Engine code: Downloading Your Source Code
I'm trying to run a web app written in Python (using Flask) on Google App Engine in the python flexible environment (needs third party libraries not provided in standard environment).
The web app contains a simple form with the option to upload a file, which my app will then use to manipulate some data and serve up a new file as output. The app in its current state runs fine until a file exceeding 32 MB is uploaded.
According to this post - Upload file bigger than 40MB to Google App Engine? - the large file upload problem can be circumvented by using the Google Blobstore API.
An overview of the API is here: https://cloud.google.com/appengine/docs/python/blobstore/
I am having some trouble understanding this overview. In particular, my problem is simply being able to import the Blobstore API in my python code for the web app. In order to obtain a an upload URL, I have placed the following in my code:
from google.appengine.ext import blobstore
upload_url = blobstore.create_upload_url('/submit')
Finally, when I try to deploy the app using gcloud app deploy, it crashes with the message ImportError: No module named 'google'.
I don't understand how I can get this running. I thought the google appengine modules were already taken care of by the App Engine. Perhaps there is a line I can add to requirements.txt so that gcloud will install the proper libraries upon deployment?
I've been googling for a solution for some time and tried a couple of ways to solve this.
In short:
I used the sample from https://cloud.google.com/appengine/docs/python/googlecloudstorageclient/getstarted to create my own uploader, but it dies on the error, mentioned here:
No api proxy found for service "app_identity_service" when running GAE script
So, from what I understand, the script needs to be uploaded to google app engine and run from there using App Engine console. But even if it's possible, how do I automate it ?
Or maybe there are other solutions I'm missing. I looked through appcfg.pya but didn't find such an option as well.
You are following a sample to upload from GAE to Cloud Storage. If your only goal is to upload files to Cloud storage, then simply use gsutil. You can easily script with gsutil, do streaming copy, copy full directories and rsync a file system.
Why you need GAE in your solution ?
Google App Engine allows you to easily upload static files and serve them but if you simply just want a place to store static files then Google Cloud Storage is the way to go. It's much easier to use the gsutil tool to automate uploading your content than deploying using the App Engine SDK. The infrastructure serving the Cloud Storage files is the same as App Engine so there's really no advantage to using App Engine's static files feature.
Also, If you need a way to set up a custom domain, index page, and/or error pages you may want to check out the guide on Configuring a Bucket as a Website.
Referencing Manage Google Drive files through App Engine, I have kind of the same question about App Engine w.r.t. Google Code Project Hosting, i.e., is there a Python API to interact with the latter using the former. Thanks!
It's possible to programatically upload files to a Google Code project, see the script at:
https://code.google.com/p/support/wiki/ScriptedUploads
What else were you looking to automate?