Here I am trying to upload a file asynchronously to the blobstore. Below is what I've done so far:
html file
<form id="my_form" enctype="multipart/form-data" method="POST"
action="/partner">
<input type="file" id="my_file" name="my_file"/>
</form>
js file
my.Project.prototype.onFileUpload = function(e) {
var uploadForm = /** @type {HTMLFormElement} */ (
goog.dom.getElement('my_form'));
var iframeIo = new goog.net.IframeIo();
goog.events.listen(iframeIo, goog.net.EventType.COMPLETE, function() { alert('request complete'); });
iframeIo.sendFromForm(uploadForm);
python code
class MyHandler(blobstore_handlers.BlobstoreUploadHandler):
def post(self):
logging.info(self.request) // I can see my file in this line's output
upload_files = self.get_uploads('my_file')
logging.info(upload_files) //upload_files come out to be an empty array
blob_info = upload_files[0]
self.redirect('/partner/serve/%s' % blob_info.key())
Any pointers on how to get the file to be uploaded from the request object.
The python code provided by google's tutorial on BlobStore can be found here.Now I am stuck. I believe if I can get the file in python code I'll be able to upload it.
Any pointers will be very helpful.
Thanks,
Mohit
BlobstoreUploadHandler will probably work best with create_upload_url("/partner") - that's what you want to set in <form action="...">
- try that and see if it works.