Blobstore - how to save data from a servlet - google-app-engine

I was looking over code google provided about how to save data on Blobstore. I need to save a large jason file. All the codes provided by google shows how to do it using a form.
I have a servlet, An android application will send the jason and the servlet will have to save that.
The DataStoreService class has a "put" method that does that but looks like blobstore does not have a "put" method.
Can someone please give me some example code that does this? Thanks so much in advance

You can save data to Blobstore programmatically via the new FileService API.

Related

Showing pictures that uploaded on express server on react in a correct way

I built an express API and uploading images with multer .
in DB I save a post with image's name and I combine it with API link and show it in this way.
enter image description here
but my problem is , I think this is not a good way to show uploaded pictures and users can see API link ، isn't it bad? i mean in a security issues
can you help me please.
No, this really isn't an issue. There isn't any problem with people knowing your API URL. If someone uses something like postman to intercept the request, they'll find it out either way. You should however secure your API if there is important data on it.

Upload Image from Post Request to Cloud function

Is there any way that the image that is uploaded by the user be directly sent to cloud function without converting to string in Python?
Thank you in advance
Instead of sending the image to the Cloud Function, it's better if the image has been uploaded to GCS. This way, you can just provide the gsUri and the Cloud Function can handle the image file by using the cloud storage client library. For example, the OCR Tutorial follows this approach.
In this case, if a function fails then the image is preserved in Cloud Storage. By using a background function when the image is uploaded, you can follow the strategy for retrying background functions to have an "at-least-once" delivery.
If you want to use HTTP Functions instead, then the only recommended way to provide the image is by converting it to string and send it inline with the POST. Note that for production environments is way better to either have the file within the same platform or send it inline.

Generate URL to store image in Datastore Blob

I am a newbie to Python and Google App Engine.
I need to store an image in GAE Datastore (not blobstore - there are lot of examples to store in blobstore and I have got it working in blobstore).
The docs has it as follows:
movie = Movie()
...
movie.picture = db.Blob(urlfetch.Fetch(picture_url).content)
movie.put()
My question is how do I obtain picture_url? I cannot use create_upload_url method since this is for Blobstore.
Thanks in advance
This question is phrased in a way no one can answer it because you need to tell people how you intend to get the the image data to begin with.
The code you're using is to download the an image from some URL and save it to you blobstore. You should be able to use any publicly accessible image url from flickr or facebook or any other website as the url. You need to decide what url you want to use.
If you want the user to upload the data, then you would need the user to issue a POST request with your image in the multipart/form-data. You would acceess the data in your request handler's request.POST object. You would not fetch it from a url in that case.
If you're using the Blobstore, GAE automatically parses the POST request data, saves it in the Blobstore, and provides a url for you. If you're not using the Blobstore, you'll only have the image data in your request object in memory.
db.Blob(urlfetch.Fetch(picture_url).content)
is for fetching images from another web sites.
if you want to store user-uploaded something, you'd better use
data = self.request.get('data') # where 'data' is the data field from your HTML form
if data :
db.Blob(data)

Appengine: Best way to read a CSV file into app inventor

I have a csv file and I'd need to get it into a list object in app inventor.
I'm not sure if there is a better / simpler method, but I've looked at the following methods and I'm not really sure the best route.
Also I'm using python but I could switch to use java app engine.
Google Fusion Tables (gft)
Google Docs & TinyGSdb
App Engine & Python
Down in the comments there is an example on how to update the app.yaml to include some code to parse a csv file.
import csv
reader = csv.reader(open(‘efile_newestSFO_8354d71d-e3fb-4864-b9bf-5312a89e24d7_2010.csv’,”rU”), delimiter=’,')
for row in reader:
print row[0],row[1]
I'd rather not go out to the web every time the app loads to retrieve the list.
Thoughts?
You can write a handler to let you upload the cvs to BlobStore, then use BlobStore APIs from your app to read the file.
That approach is well-described here (in Java, but the same idea applies to Python).

Uploading multiple files to blobstore (redux)

Yes, I've seen this question already, but I'm finding information that contradicts its accepted answer and Nick Johnson's blog on the GAE docs.
The docs talk about uploading more than one file at the same time - the function to get uploaded files returns a list:
The get_uploads() method returns a
list of BlobInfo objects, one for each
uploaded file in the request.
But everywhere I've looked, the going assumption is that only one file a time can be uploaded, and a new upload url needs to be created each time.
Is it even possible to upload more than one file at the same time using HTML5/Flash using Plupload?
Currently, the blobstore service upload URLs only support one file upload per post. In order to upload multiple files, you need to use the pattern documented in my blog posts. In future, we may extend the blobstore API to support more flexible upload URLs, supporting multiple uploaded files in a single request.
Edit: The blobstore now supports multiple file uploads in a single request.
Here's how I use the get_uploads() method for more than one file:
blob_info = self.get_uploads()[0]
blob_info2 = self.get_uploads()[1]
Nick Johnson's dropbox service is another example and I hope you find what suits your needs.

Resources