简体   繁体   中英

How to get the direct url of a binary file in the Google Blobstore?

My application generates binary data (compressed xml) and saves it to the Google App Engine Blobstore. I want to return a public URL that clients can use to access this binary file from anywhere, without needing to go through AppEngine and my Java servlets. I know it's possible to get this kind of URL for images using ImagesService#getServingUrl , but what about for other types of files?

I create my file like this:

FileService#createNewBlobFile("application/octet-stream", "myfile.bin");

When I call AppEngineFile#getFullPath() I get something like:

/blobstore/writable:a2c0noo4_LNQ0mS6wFdCMA

I can see the file created in my dev filesystem with a different random name. What's its URL?

You can use Google Cloud Storage for your file.

You can then provide a public cloud storage URL for you file that will allow you clients to download it without going through AppEngine. There are a whole lot of different ACL scenarios you can use to tighten down the access as well, it's in the docs.

Using Google Cloud Storage with the Files API.

Cloud Storage Docs.

According to the docs, there's no public URL for objects in the blobstore. You can only access it through the Blobstore API from your app. So if you want your blobstore objects to each have a URL, you'd have to create your own handler for that, which of course will have to pass through AppEngine and your Java servlets.

I think the ImagesService#getServingUrl doesn't generate a Public URL for the images in blobstore. That URL doesn't really point directly to your blobstore data. It points to an image service that is able to access your blobstore, and serves your image for you through its own high performance infrastructure.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM