我这里有一个公共桶:http://storage.googleapis.com/tripket1/
并且这个桶中的所有文件都将ACL设置为“公共读取”。但是,当我试图查看任何文件时,例如:
它返回一个'NoSuchKey‘错误。
<Error>
<Code>NoSuchKey</Code>
<Message>The specified key does not exist.</Message>
</Error>是什么导致了这个问题?这些文件是使用GCS客户端库为Java上传的。下面是上传程序中的一个代码片段:
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;发布于 2013-09-17 15:41:27
您需要转义对象名称中的%字符。
例如,您有以下对象:
gs://tripket1/2013-05-25%2019.17.32_150.jpg由于在对象的名称中有一个文字百分比符号,所以在进行%25编码时必须将其转义为,因此可以使用该URL访问该对象:
如果您不转义它,那么在服务器端解码时,对象名称中的%20将被转换为空格(),并且它不会找到带有空格的对象名。
发布于 2013-09-17 12:31:53
因为它是一个公开可读的桶,所以我使用gsutil来查看它的内容,并且我看到您试图读取的对象名为
2013年-05-25%2019.17.32_150.jpg
而不是
06b78005-4ad8-43d6-8fc5-bab867b653af/2013-05-25%2019.17.32_150.jpg
https://stackoverflow.com/questions/18845762
复制相似问题