How does one get image data (image url, image info) from datastore through an api?
Is there a tutorial or a project that lets you upload images like FotoRatan but also has an api which can be used to get the image and image info from another website?
Here is an example how to store and serve files (maybe images) using Blobstore: http://code.google.com/appengine/docs/java/blobstore/overview.html#Uploading_a_Blob
You should also look at Picasa Web Albums Data API
Related
I have a zipped file containing images which I am sending as response to a python REST API call. I want to create a rest application which consumes the python rest api in this manner: The response's content should be extracted without downloading (in browser side) and all the images should be displayed to the user. Is this possible? If yes, could you please help me in the implementation? I am unable to find help anywhere.
I think what you are trying to do is have a backend server (python) where zip files of images are hosted. You need to create an application (that could be in react) that
Send HTTP calls to the server get those .zip files.
Unzip them. How to unzip file on javascript
Display the images to the user. https://medium.com/better-programming/how-to-display-images-in-react-dfe22a66d5e7
I'm not sure what utf-8 has to do with this, but this is possible. A quick google gave me the results above.
I need to display/stream large video files in reactjs. These files are being uploaded to private s3 bucket by user using react form and flask.
I tried getObject method, but my file size is too large. get a signed url method required me to download the file.
I am new to AWS-python-react setup. What is the best/most efficient/least costly approach to display large video files in react?
AWS offers other streaming specific services but if you really want to get them off S3 you could retrieve the files using torrent which, with the right client/videoplayer would allow you to start playing them without having to download the whole file.
Since you mentioned you're using Python, you could do this using AWS SDK like so:
import boto3
s3 = boto3.client('s3')
response = client.get_object_torrent(
Bucket='my_bucket',
Key='/some_prefix/my_video.mp4'
)
The response object will have this format:
{
'Body': StreamingBody()
}
Full docs here.
Then you could use something like webtorrent to stream it on the frontend.
Two things to note about this approach (quoting docs):
Amazon S3 does not support the BitTorrent protocol in AWS Regions launched after May 30, 2016.
You can only get a torrent file for objects that are less than 5 GBs in size.
I am making an application in which the users can upload some pictures so that others can see them. Since some of these can be a bit large, I need to generate smaller images to give a preview of the content.
I already have the uploaded images in GCS, in urls with the form: "https://storage.googleapis.com/...", but from what I can see in the Images API docs, it uses the blobstore, which I am not using (it's been superseded). How can I serve the thumbnails from the gcs link to avoid making the users load the full image? I would really appreciate any code example.
UPDATE:
I tried to copy the example with an image from my app using images.Image with filename as suggested, but it gives me a TransformationError, and a NotImageError if I don't try any transformations:
def get(self):
teststr ='/gs/staging.trn-test2.appspot.com/TestContainer/Barcos-2017-02-12-145657.jpg'
img = images.Image(filename=teststr)
img.resize(width=80, height=100)
thumbnail = img.execute_transforms(output_encoding=images.JPEG)
self.response.headers['Content-Type'] = 'image/jpeg'
self.response.out.write(thumbnail)
What am I missing?
In general you can use the Blobstore API, but with GCS as underlying storage instead of the Blobstore, see Using the Blobstore API with Google Cloud Storage. IMHO just the storage is superseded, not the API itself:
Note: You should consider using Google Cloud Storage rather than Blobstore for storing blob data.
For the Image class in particular (from your link) you can use the filename optional constructor argument instead of the blob_key one (which triggers the above-mentioned blobstore API + GCS usage under the hood):
filename: String of the the file name of a Google Storage file that
contains the image data. Must be in the format
`/gs/bucket_name/object_name`.
From its __init__() function:
if filename:
self._blob_key = blobstore.create_gs_key(filename)
else:
self._blob_key = _extract_blob_key(blob_key)
I have the Google picker set up, as well as Blobstore. I'm able to upload files from my local machine to the Blobstore, but now I have the Picker set up, it works, but I don't know know how to use the info (url? fileid?) to then load that selected file into the Blobstore? Any tips on how to do this? I haven't been able to find much of anything on it on Googles resources
There isn't a direct link between the Google Picker and the App Engine Blobstore. They are kind of different tools for different jobs. The Google Picker is designed as an end user tool, to select data from a users Google account. It just so happens that the Picker also provides an upload interface (to Google Drive) as well. The Blobstore on the other hand, is designed as a blob storage mechanism for your App Engine application.
In theory, you could write a script to connect the two, but there are a few considerations:
Your app would need access to the users Google Drive account using OAuth2. This is necessary, as the Picker API is a client side API, whereas the Blobstore API is a server side API. You would need to send the selected document URL to the server, then download the document and finally save it to Blobstore.
Unless you then deleted the data from Drive (very risky due to point 3), your data would be persisted in 2 places
You cannot know for sure if the user selected an existing file, or uploaded a new one
Not a great user experience - the user things they are uploading to Drive
In essence, this sounds like a bad idea! What is your use case?
#Gwyn - I don't have enough reputation to add a comment to your solution, but I had an idea about problem #3: You cannot know for sure if the user selected an existing file, or uploaded a new one
Would it be possible to use Response.VIEW to see what view they were using when the file was selected? If you have one view constructor for Drive files and one for Upload files, something like
var driveView = new google.picker.View(google.picker.ViewId.DOCS);
var uploadView = new google.picker.DocsUploadView();
would that allow you to know whether the file was a new upload (safe to delete) or an existing file (leave it alone)?
Assuming that you want to pick a file from your own Google Drive and move it to the Blobstore.
1)First you have to perform Oauth for Google Drive API
2)Using the picker when you select a file from drive, you need to get it's id
3)Using the id obtained in step 2 you can programmatically download it using Drive API
4)After downloading the file you can use FileService(deprecated though) to upload the file to the
Blobstore.
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)