I want to
set a name to every blob(image or video) using blob store in GAE and
retrieve it later.
How can this be done in java (is given in Python). So can anyone tell me how can I do this. How can I use the name to retrieve the blob again?
I want to send and retrieve these images from an android device to the google cloud.
I have posted a similar question before as well but did not got a handy answer.
You have to use a blobkey to get a blob. If you want to use another name (like the filename) you have to store this name and the blobkey to get the blob. Only the blobkey is unique. For instance if you upload the same filename multiple times, these uploaded blobs will have unique blobkeys, but they do not have unique filenames.
See also : Google AppEngine Blobstore: Downloading a Blob by Filename in Java
Related
I got a web application with a Java backend and React frontend. It allows users to upload and display pictures like in an album setting.
The application fetches data from a MS SQL server containing data about an image and then displays it in react.
The database contains a table with information about the image (filename, extension etc.) but not a BLOB.
I am currently displaying the image in react by creating an url from my local machine.
My question is now, what file system alternatives is there when i want to stop storing the images locally on my windows machine. Is it possible to use Google Drive API or something similar? What about SFTP? Would appreciate free solutions to begin with.
You can use Amazon S3 to store your images. store information about the image like file name, bucket name ,... etc in your database and store the image itself in Amazon S3.
There are also other alternatives to Amazon S3 if you want, like MinIO, which is open source and S3 compatible.
I'm using JAVA Blobstore API to upload files directly to the GCS. I have followed this
https://cloud.google.com/appengine/docs/java/blobstore/#Java_Using_the_Blobstore_API_with_Google_Cloud_Storage
This is working seamlessly. But when I tried to view or download the file, from GCS, its actually showing a different name than I uploaded. Its happening while uploading itself. I think, It takes a random blobkey as file name.
Is there any way to change the filename in GCS after uploading programatically, or any way to upload with custom name using Blobstore API.
Any help would be greatly appreciated.
Thanks.
It's not possible to set the name for files uploaded to GCS via Blobstore API. Direct object renaming is not possible on GCS. As a workaround you can:
Get object name from returned FileInfo.
Copy object to a new object of desired name.
Delete old object.
I have an App Engine Connected Android Project, so I am using endpoints. I ultimately converted the bitmap from my Android project into an encoded string to use in my setter, where I converted this string back into a byte array and then to a Blob, and then persisted the blob to the datastore. I know when to retrieve this Blob and display it as the actual image on the app engine front end. How can I do this? I'm a very beginner, especially with using Blobs.
As stated in the official docs.
If you are serving images, a more efficient and potentially
less-expensive method is to use getServingUrl() using the App Engine
Images API rather than blobstoreService.serve(). The getServingUrl
method lets you serve the image directly, without having to go through
your App Engine instances.
So basically having a blobkey you can use
ServingUrlOptions options = ServingUrlOptions.Builder
.withBlobKey(blobKey);
String url = imagesService.getServingUrl(options);
And access that image as "static" content hosted by Google without going through your server.
I'm trying to save a file in google cloud storage using Blobstore API in my servlet.
That worked but the problem is that the file name in GCS is not the same as the original file name was (Seems that it's just blobkey).
Can I do the same but have the original file name in GCS?
I just recently went through the same process and after some head scratching was able to figure things out. Check this link for my answer.
google app engine java error using blobstore api to retrieve file from cloud storage
The short version is that your callback servlet needs to use the string returned from the method getGsObjectName().
Hope this helps!
ok, I came to this:
No. In the GCS files are saved with generated key as its name. (But its possible to save original file name somewhere else)
I have image URLs like http://example.com/someimage.png - how do I fetch that image and save it with Blob? Thanks.
Here's example code from the documentation showing how to write a file to the blobstore. You'll have to use a stream instead of a writer, since a PNG image is binary, and you'll have to set the appropriate content type, but it should show you the way.
And here's the UrlFetch documentation, explaining how to get some available resource on the web, using HTTP.