How do I work on multiple appengine projects with python? - python

I need to export my blobstore from one appengine project and upload it to another project. How can I switch between projects programmatically with python?

If by "python" you mean a python GAE app's code itself - AFAIK you can't switch apps - each such code runs only inside the app specified in the .yaml file.
You could teach the exporting app project to serve the blob and for the actual transfer you could either:
have the receving app directly pulling the blobs from the exporting app
have an external (python) script pull blobs from the exporting apps and uploading them to the importing app.
Either way you'd need to write some code to actually perform the transfer.
So instead of doing that, I'd rather write and execute a one-time conversion script to move the data from blobstore (presently shown in the GAE python docs under Storing Data > Superseded Storage Solutions section on the left-side menubar) to the Datastore or GCS, both of which have better backup/restore options, including across apps :) GCS can probably be even used to share the same data across apps. And you can still serve the GCS data using the blobstore API, see Uploading files directly to Google Cloud Storage for GAE app
If you mean some external python app code - AFAIK the blobstore doesn't offer generic access directly to an external application (I might be wrong, tho). So an external app would need to go through the regular upload/download handlers of the 2 apps. So in this case switching between projects really means switching between the 2 apps' upload/download URLs.
Even for this scenario it might be worthy to migrate to GCS, which does offer direct access, see Sharing and Collaboration

Related

What Google app engine Auth to use to only expose my "intranet" site only to my GSuite users?

I am pretty new Google app engine, and though I have hacked around with alot of languages, I am finding the google documentation a little overwhelming. I have successfully launched a static site, and successfully run some python code from the console. But I have not run any python from my static site.
I am a Small company trying to setup a google app engine static/dynamic website that I only want to expose to my Gsuite users.
I have some python code I want to run on my app engine, which will download a file from gdrive/teamdrive, process the file, create a new file from the results and then upload the resulting file to the same folder.
I may also at a later date have this static/dynamic website also interfacing with Cloud SQL(mysql) or an external database.
my Questions
What authentication method to use to only expose this website to my gsuite users?
Though I have worked through some of the GDrive api examples whats the best and easiest method of passing GDrive text files to my python code? (though I have hacked around with python lots in the past, the html and python combination perplexes me)
Thanks!
You would use OAuth2.0 to acquire a token which you can then use to interact with that user's files through the GDrive API (see "About Authorization" as well as this quickstart Python example).

How can I edit the NGINX configuration on Google App Engine flexible environment?

How can I edit the Google App Engine NGINX configuration?
There doesn't seem to be much support in the Google docs in regards to the NGINX configuration for apps running in the Google App Engine flexible environment.
My app is running fine, but I get this 413 error when I try and upload an audio file (.wav or .mp3).
413 Request Entity Too Large -- nginx
My app is running Django (python 3), with Cloud Postgres SQL and Cloud Storage enabled.
I researched the error, and it seems I can set a nginx.config file so that it includes "client_max_body_size 80M" - but like I said, there is no documentation regarding how to manually config NGINX on deploy.
Any suggestions?
You should be able to create a nginx-app.conf file in the same directory as your app.yaml file. There is an example of using the nginx configuration file in a Flex environment located here: https://github.com/GoogleCloudPlatform/getting-started-php/tree/master/4-auth .
This same file is referenced in Google's documentation here: https://cloud.google.com/appengine/docs/flexible/php/runtime#customizing_nginx
Once you have that file created, you should be able to add any property you need and then rebuild your project to see the changes take effect.
So upon contacting Google Support, the suggested solution for uploading files larger than 32MB is as follows:
"The way to circumvent App Engine's 32MB limit is to send the requests directly to Cloud Storage, for instance using the resumable upload process. You can still use App Engine to serve your app, but the clientside portion of the app would be the one handling the upload to Google Cloud Storage. For this you would have your application generate a signed URL which the client can use to gain access to your Cloud Storage bucket for the purpose of uploading an image."
I went with this solution. It saves money in the end.

How can I update one (or a couple) files in a Google App Engine Flask App?

If I'm just updating, say, my main.py file, is there a better way to update the app then running gcloud app deploy, which takes several minutes? I wouldn't think I need to completely blow up and rebuild the environment if I'm just updating one file.
You must redeploy the service. App Engine isn't like a standard hosting site where you FTP single files, rather you upload a service that becomes containerized that can scale out to run on many instances. For a small site, this might feel weird, but consider a site serving huge amounts of traffic that might have hundreds of instances of code running that is automatically load balanced. How would you replace that single file in that situation across all your instances? So you upload a new version of a service and then you can migrate traffic to the new version either immediately or ramped up.
What you might consider an annoyance is part of the tradeoff that makes App Engine hugely powerful in not having to worry about how your app scales or is networked.

how to allow my own google drive app to only upload files

I want to develop a backup app, I wish that the app will be able only to upload files without any permissions to delete files (or any other permission).
is it possible ?
Yes, it's possible. Start by looking for a python library that lets you communicate with the Google Drive API. See Google APIs Client Library and PyDrive (you'll find easy code as example here).

Accessing Google Groups Services on Google Apps Script in Google App Engine?

I'm trying to work out if it is possible to use Google Apps Scripts inside Google App Engine?
And if there is a tutorial in doing this out there ?
Through reading Google's App Script site I get the feeling that you can only use app scripts inside Google Apps like Drive, Docs etc?
What I would like to do is to be able to use the Groups Service that is in GAS inside GAE to Create, delete and only show the groups that a person is in, all inside my GAE App.
Thanks
No you can't. AS and GAE are totally different things and won't work together.
What you can really do is (abstract):
write an AS that does what you need
redirect from GAE to the AS url to make sure that the user logs-in/grants permissions.
perform what you needed to do with AS
send back the user to GAE with a bunch of parameters if you need to
If you need GAE in Google Apps script, you can write a webservice in GAE using UrlFetch in Apps Script: https://developers.google.com/apps-script/service_urlfetch
To give you an example: I created an Apps Script to get report data (json) from an appengine webservice. This data is added to a google apps spreadsheet.

Categories