Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Directly Putting Data in AppEngine's Blobstore

The AppEngine's standard API assumes files are uploaded from an HTML form. I'm trying to post a file to the blobstore from a REST API method that can be called by a non Html client (Flash, iPhone, etc.)

The code I'm trying to get working:

# Get the blobstore upload url    
upload_url = blobstore.create_upload_url("/activities/upload_finished");

# Make sync call to the blobstore url to post our image
result = urlfetch.fetch(url=upload_url,
                        payload=request.FILES,
                        method=urlfetch.POST,
                        headers={'Content-Type': 'multipart/form-data'})

I'm getting the following error:

ValueError: Invalid boundary in

Any idea?
Has anyone tried posting to the blobstore not through a web form?

multipart form: ''

like image 615
Eran Kampf Avatar asked Jan 27 '10 18:01

Eran Kampf


People also ask

How do I add data to Datastore?

Click Datastores in the Supported Operations list. Click Add to Server. Paste your data store item ID in the DatastoreId field. Paste the ID of your federated server in the ServerId field.

What is blobstore cloud storage?

The Blobstore API allows your application to serve data objects, called blobs, that are much larger than the size allowed for objects in the Datastore service. Blobs are useful for serving large files, such as video or image files, and for allowing users to upload large data files.


2 Answers

App Engine (version 1.4.3) allows you to directly write data to the blobstore.
You no longer need to use the upload url method.

like image 112
Shay Erlichmen Avatar answered Oct 16 '22 15:10

Shay Erlichmen


You can't make a regular post into a multipart form simply by specifying the content type - you're just submitting URL-encoded data with the wrong content type.

You'll need to assemble a proper multipart form - using the email module or by hand, like this.

Also see this question.

like image 45
Nick Johnson Avatar answered Oct 16 '22 14:10

Nick Johnson