Ishita Kalsi
Ishita Kalsi

Reputation: 53

Using slash character in s3 key

I am storing files to s3 in the format - "abc/xyz/Name.pdf"

In, some cases Name variable is like "%s/%s".

Since a slash character '/' is existing in the the Name variable, s3 console is creating a subfolder with name as - characters in Name before '/' and is creating the filename as - characters in Name after '/'.

But i need to download the file with whole variable Name as the filename.

How can i achieve this?

Upvotes: 1

Views: 3525

Answers (1)

Chris Williams
Chris Williams

Reputation: 35188

There is no such thing as a subfolder in S3. In fact what you see as a folder hierarchy is just a user interface displaying each part of a prefix split by the "/" character as if it is a seperate folder.

In fact the AWS interface is just filtering object keys by prefix.

There is no way to specifically count a single "/" as if its part of "the filename" in the GUI. You can however encode characters in your filename so that the GUI will not display like this.

Alternatively you can use the CLI with the list-objects command to apply your own filtering logic.

Upvotes: 3

Related Questions