Reputation: 82
I have a public bucket here: http://storage.googleapis.com/tripket1/
And all the files in this bucket have the ACL set to 'public-read'. Yet when I try to view any of the files, such as:
http://storage.googleapis.com/tripket1/2013-05-25%2019.17.32_150.jpg
it returns a 'NoSuchKey' error.
<Error>
<Code>NoSuchKey</Code>
<Message>The specified key does not exist.</Message>
</Error>
What could be causing this problem? These files were uploaded using the GCS client library for Java. Here's a code snipped from the uploader:
GcsFilename thumbGcsFilename = new GcsFilename(bucketName, thumb_filename);
GcsFileOptions options = new GcsFileOptions.Builder().mimeType("image/" + photo_extension).acl("public-read").build();
GcsOutputChannel outputChannel = gcsService.createOrReplace(thumbGcsFilename, options);
outputChannel.write(ByteBuffer.wrap(newImageData));
outputChannel.close();
LOGGER.info("Wrote file");
String thumb_url_str = String.format("http://storage.googleapis.com/%s/%s", bucketName, thumb_filename);
return thumb_url_str;
Upvotes: 2
Views: 10560
Reputation: 67063
You need to escape the %
character in your object names.
For example, you have the following object:
gs://tripket1/2013-05-25%2019.17.32_150.jpg
Since you have a literal percent sign in your object's name, it must be escaped as %25
when URL encoded, so you can access the object with this URL:
http://storage.googleapis.com/tripket1/2013-05-25%252019.17.32_150.jpg
If you don't escape it, the %20
in your object name gets turned into a space () when being decoded at the server side, and it doesn't find an object name with a space in it.
Upvotes: 3
Reputation: 12145
Since it's a publicly readable bucket, I used gsutil to look at its contents, and I see the object you're trying to read is called
2013-05-25%2019.17.32_150.jpg
rather than
06b78005-4ad8-43d6-8fc5-bab867b653af/2013-05-25%2019.17.32_150.jpg
Upvotes: 0