File upload to a Google Cloud Storage Signed URL in Python - python

Can someone help me with the code to upload a file to a Google Cloud Storage Signed URL in Python, preferably using the Requests library?

You can have a look at this sample code on Github. It shows a portable way to achieve this using PyCrypto and requests.
Note that, if your app is running on App Engine, you can easily sign the string using the App Engine Identity service and its sign_blob() method, as documented here.

Here is sample code for AppEngine app using sign_blob() as mentioned in LundinCast's answer. I verified that it works.

Related

What are the possible ways to automate uploading static files to GoogleAppEngine?

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.

Processing data from Google App Engine on a Google Virtual Machine

My website runs on Python on Google App Engine, and I've setup a Virtual Machine to use libraries that weren't supported by the default App Engine environment. Now I need to send data from my app to the VM and retrieve the response. Data in this case will be an email address and an email message.
Currently I am testing with a POST request through urllib2. Is there a better way to do this?
Sticking with the described POST request using urllib2. We decided we might move this part of the project to a different provider so better to not use Google Cloud only methods.

Python App Engine API to interact with Google Code Project Hosting

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?

Using OAuth Python service with Google App Engine

Google App Engine provides an experimental, bleeding-edge OAuth service in its Python SDK, but fails to provide simple example to work with. Has anyone succeeded in working with it? If so, could you provide a snippet? 
Here is a very good tutorial

Anybody tried mosso CloudFiles with Google AppEngine?

I'm wondering if anybody tried to integrate mosso CloudFiles with an application running on Google AppEngine (mosso does not provide testing sandbox so I cann't check for myself without registering)? Looking at the code it seems that this will not work due to httplib and urllib limitations in AppEngine environment, but maybe somebody has patched cloudfiles?
It appears to implement a simple RESTful API, so there's no reason you couldn't use it from App Engine. Previously, you'd have had to write your own library to do so, using App Engine's urlfetch API, but with the release of SDK 1.1.9, you can now use urllib and httplib instead.

Categories

Resources