简体   繁体   English

AWS S3 SDK 创建带有尾部正斜杠的文件夹

[英]AWS S3 SDK creates folders with trailing forward slash

I have googled this extensively and not found any post commenting on this problem.我用谷歌搜索了很多,没有找到任何评论这个问题的帖子。 Using the code below I upload a file to a path in AWS S3 which creates the new path and adds the file: BucketName + NewFolderName + FileName使用下面的代码,我将文件上传到 AWS S3 中的一个路径,该路径创建新路径并添加文件:BucketName + NewFolderName + FileName

However, it adds a forward slash in the path as shown below.但是,它会在路径中添加一个正斜杠,如下所示。

在此处输入图像描述

The screenshot below shows the code I'm using and as you can see the “BucketName” property which contains the target path does not have the trailing forward slash.下面的屏幕截图显示了我正在使用的代码,如您所见,包含目标路径的“BucketName”属性没有结尾的正斜杠。 Can someone please tell me why it adds this slash and how to prevent it?有人可以告诉我为什么要添加这个斜线以及如何防止它吗?

在此处输入图像描述

Thank you.谢谢你。

In AWS s3 everything is a key value pair.在 AWS s3 中,一切都是键值对。 In the GUI (s3 dashboard) it is rendered so that you get the file system like structure.在 GUI(s3 仪表板)中呈现它,以便您获得类似文件系统的结构。 The trailing slash depicts that its a key prefix meaning there are multiple objects with that key prefix (equivalent of saying multiple files inside a folder ).尾部斜杠表示它是一个键前缀,这意味着有多个对象具有该键前缀(相当于说一个文件夹中的多个文件)。 If no trailing slash is there, that is the end of the key.如果没有尾部斜杠,则密钥结束。

In your case "Bold2.png" is the end of the key string, whereas "testsubdir" is part of the key (substring not ending).在您的情况下,“Bold2.png”是密钥字符串的结尾,而“testsubdir”是密钥的一部分(子字符串未结束)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM