我在计算机引擎上运行的应用程序创建了我上传到云存储的图像。 这很好用
BlobInfo blobInfo = storage.create( BlobInfo .newBuilder(bucketName, fileName) .setAcl(new ArrayList<>(Arrays.asList(Acl.of(User.ofAllUsers(), Role.READER)))) .build(), filePart.getInputStream());但我需要将其上传到特定的文件夹,如'bucketname / 170717 /'
找不到上传到特定文件夹的方法。 任何指针将不胜感激。
My application running on computer engine creates images which I upload to cloud storage. This works well using
BlobInfo blobInfo = storage.create( BlobInfo .newBuilder(bucketName, fileName) .setAcl(new ArrayList<>(Arrays.asList(Acl.of(User.ofAllUsers(), Role.READER)))) .build(), filePart.getInputStream());But I need to upload this to specific folder like 'bucketname/170717/'
Couldn't find way to upload to specific folder. Any pointers would be appreciated.
最满意答案
所以最后我得到了解决方案。
storage.create(BlobInfo .newBuilder(bucketName,fileName)
在上面的代码片段中,如果fileName具有文件夹路径,则云存储会创建它。 因此,当我传递“images /”+ fileName时,创建了一个新的文件夹图像,并在其中创建了文件。
So finally I got the solution.
storage.create( BlobInfo .newBuilder(bucketName, fileName)
In above snippet of code if fileName has a folder path, cloud storage creates it. So when I passed "images/" + fileName a new folder images was created and file was created inside that.
更多推荐
发布评论