The URL of the file uploaded to GCS is not updated.

Asked 1 years ago, Updated 1 years ago, 101 views

Thank you for your help.

Environment
Java: 1.7
Eclipse: 4.3
GAE: 1.9.30
servlet:2.5
appengine-gcs-client:0.5

Servlet now uploads the image file to GCS and returns the URL of the file. Yes, I work with GCS using the GCS Client Library.

Uploading the file to GCS and uploading another image with the same file name
If you access the URL, the first uploaded file is displayed.
According to GCS, the file has been updated, but only the URL seems to be cached.

How do I generate a URL?
ImagesService#getServiceUrl
and
Make acl public-read and get public URL
I tried these two patterns, but they both seem to be cached.

I would like you to disable the operation of this cache and always return the URL of the new file.
Isn't there anyone who can do it like this?
I was told that it would be good to resize using ImagesService, but I would like to go without resizing
I think so.

I touched cacheControl("max-age=15") and the cache control.
It didn't work.

Thank you for your cooperation.

追Additional
The URL was successfully obtained.It seems to have been cached when I replaced the URL.

java google-app-engine servlet

2022-09-30 14:33

1 Answers

The Image Service uses the G+Photo infrastructure on the back, and it caches files from Blobstore or Cloud Storage into G+Photo.
I don't think it has a function to control the cache period.

If you don't want to use the cache at all, I think it's better for App Engine to distribute Cloud Storage files using BlobstoreService.
As for BlobstoreService, I think it would be good to look at Part 2 where files are handled in GAE/j.
Later, if BlobstoreService handles files that already exist in GCS, use
Java_Using_the_Blobstore_API_with_Google_Cloud_Storage to create BlobKey.
Actually, when I write the code, it looks like this.
If you want to edit the HTTP Response Header, you can edit it before you do BlobstoreService.serve(blobKey, response);

BlobstoreServiceblobstoreService=BlobstoreServiceFactory.getBlobstoreService();
        BlobKey BlobKey=
                blobstoreService.createGsBlobKey("/gs/"+fileName.getBucketName()+"/"
                        + fileName.getObjectName());
        blobstoreService.serve(blobKey, response);


2022-09-30 14:33

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.