如何通过api将文件上传到云存储上的特定文件夹(How to upload files to specific folder on cloud storage via api)

编程入门 行业动态 更新时间:2024-10-27 12:42:10
如何通过api将文件上传到云存储上的特定文件夹(How to upload files to specific folder on cloud storage via api)

我在计算机引擎上运行的应用程序创建了我上传到云存储的图像。 这很好用

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.

更多推荐

本文发布于:2023-08-06 18:11:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1454232.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件夹   文件上传   upload   api   files

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!