我使用云代码创建了密钥并将其添加到Env中。现在,我尝试读取存储桶,但不允许我读取内容。
我收到以下异常
java.io.FileNotFoundException:无法打开ServletContext资源[/gs://mybucket/my-file.txt]
@RestController
public class Controller {
@Value("gs://mybucket/my-file.txt")
private Resource gcsFile;
@RequestMapping(value = "/readgcs", method = RequestMethod.GET)
public String readGcsFile() throws IOException {
return StreamUtils.copyToString(
gcsFile.getInputStream(),
Charset.defaultCharset()) + "\n";
}
}