I have a chunk of text in a big string I create dynamically in javascript in a web app. I want to save it to the blob store. However, I can't figure out how to make it work. I am creating the URL to post to with the usual blobstoreService.createUploadUrl() command.
One possibility for posting my string to the blobstore url is to use jQuery.ajax:
jQuery.ajax({url:blobstore_url,contentType:'multipart/form-data',type:'POST',data:{file:mystring}})
However, when i run this command I get the AppEngine error "java.lang.OutOfMemoryError: Java heap space". Googling this error suggests my form data is missing the required "name" attribute, but I cannot figure out how to specify this using jQuery.ajax.
Another possibility is to use the browser's FormData object:
formData = new FormData()
formData.append("file",my_string)
xhr = new XMLHttpRequest()
xhr.open("POST", blobstore_url)
xhr.send(formData)
This runs fine, but then when my "success" url is triggered by the blobstore in my AppEngine server app, the list of posted blobs is empty. I assume I can't just append my_string to the formData as a file object but need to do something else instead.
I know I'm extremely close to having this working, but am missing some important little detail. If any of you can help me figure out how to fix either of the two approaches above I would be elated- Thanks!