Move file around in s3 in the browser - amazon-web-services

Is there a way to move a file/folder somewhere in the same bucket but in another place in the hierarchy using only the browser.
I know there is s3fuse or command line tools but I want to do it in the browser.

Using the AWS Console, you can right click on the original file, select Cut and then go to the new location and select Paste. This will move the file from the old location to the new one.

Related

AWS S3 how to make folder as today's date

I would like to create a folder structure displayed like below.
How should I specify the key?
*Top level folder would be today's date
/yyyymmdd/*.jason
e.g.
/2021-05-21/example.json
Folders do not actually exist in Amazon S3. You can create an object with any path and the folder magically 'appears'. Then, if the object is deleted, the folder will disappear. Amazon S3 calls them CommonPrefixes.
The Amazon S3 management console has a "Create Folder" button. This actually creates a zero-length object with the same name as the folder (e.g. 2021-05-21/). This 'forces' the folder to appear because there is an object inside it. However, the zero-length object is hidden in the console.
So, if you wish to 'create a folder', simply create a zero-length object with the name of the folder.
Or, better yet, do not create the folder. Just pretend that it exists and things will work perfectly fine.

How to move S3 data to one partition level up?

Let's say I have a table in the path
s3:bucketname/tablename/month/day/deviceid
I want to move all files to s3:bucketname/tablename/month/day/. In other words, I want to ignore the last partition.
Note that there are already data in the path s3:bucketname/tablename/month/day/
Can I use aws s3 to achieve this?
I have more than 100K files so I cannot do this manually.
I believe you can use the AWS console on the web. Open the source folder (deviceid), select all its contents by the checkbox to the left on Name.
Then select Actions → Copy.
Open the destination folder (day), click Actions → Paste. Confirm the operation.
Once the operation has finished successfully, you can delete the source folder with all its contents.
You can do this in 2 ways.
If you are not familiar with the aws cli, then go to the console, select all the files, cut and paste on the desired directory. However, this is very time consuming and inefficient task.
I recommend the aws cli for S3. You can find some sample commands here.

Delete object from AWS S3 bucket (not in code)

I just want to update my index.html file in an S3 bucket. I was going to delete the file and then add the new one just using the website. I can't see any way to do this. Am I thinking wrong? Am I supposed to do all this stuff in code? I just want to hack it together for now so can I do it on the website?
In the console, you can select your file, click "More" and delete is one of the options. There's the upload button to the left as well. I also suggest getting familiar with the AWS CLI so that you also can sync directories and such.
You can go into S3 select a single file and delete it. Afterwards you can upload a new file.
Old console: Select the file in S3 and click Actions and then click delete.
New console: Select the file in S3 and click More and than click delete.
You could use a client like Cyberduck as well.

Inconsistent behavior in Amazon S3 for folder/key upload, delete through console

There seems to be some inconsistency in Amazon S3's behavior.
If in bucket a "Bucket1", I create folder "Folder1" and upload a file say "sample.txt" into it. Next I delete this file. At the bucket level I can see "Folder1" on S3 Console.
Now in the same bucket if I upload a file "Folder2/sample.txt" and just delete sample.txt file, then Folder2 also disappears from console?
Why this inconsistency? AFAIK we do not have any API to create/delete folder at SDK level.
Am I missing something here or is this an actual issue?
Thanks in advance for any help.
A "Folder" in S3 is simply a 0-byte object with a / character at the end of the key name.
So, using the AWS CLI or SDKs, you can "create a folder" by "putting" an object that matches those criteria.
The AWS Management Console also does something extra: it simulates folders, even of they were not explicitly created. So, if you uploaded your object as "Folder2/sample.txt", it extrapolates and simulates "Folder2/" at the parent folder level. You can do this yourself with the CLI/SDKs using the delimiter parameter.
When you delete that object, since "Folder2" did not actually exist as a 0-byte object ending with / (see first paragraph), then "Folder2/" disappears from the management console.

Is there any way to get s3 uri from aws web console?

I want to download a directory from my s3.
When I need a file, the s3 management console (aws web console) allows me to download it, but when a directory, I have to use aws-cli, like:
$ aws s3 cp s3://mybucket/mydirectory/ . --recursive
My question is: Is there any way to get the s3 uri (s3://mybucket/mydirectory/) from s3 management console?
It's URL is available, but it is slightly different from s3 URI required by aws-cli. I could not find any menu to get the uri.
Thank you in advance!
No, it is not displayed in the console. However, it is simply:
s3://<bucket-name>/<key>
Directories are actually part of the key. For example, foo.jpg stored in an images directory will actually have a key (filename) of images/foo.jpg.
(self-answer)
Because it seems there was no such way, I have created one:
pip install aws-s3-url2uri
And command aws_s3_url2uri will be available after installation.
This command internally converts the web console URLs to S3 URIs, so works with URLs and URIs and local paths:
aws_s3_url2uri ls "https://console.aws.amazon.com/s3/home?region=<regionname>#&bucket=mybucket&prefix=mydir/mydir2/"
calls
aws s3 ls s3://mybucket/mydir/mydir2/
internally.
To convert an S3 URL displayed in the console such as https://s3.us-east-2.amazonaws.com/my-bucket-name/filename to an S3 URI, remove the https://s3.us-east-2.amazonaws.com/ portion and replace it with s3://, like so:
s3://my-bucket-name/filename
It looks like this feature is now available in the AWS Web Console.
It is accessible in two ways:
Selecting the checkbox next to the file and clicking on "Copy S3 URI" button.
Clicking on the file, and clicking on the "Copy S3 URI" button on the top right.
You can get the value from the console by selecting the file in the console. Choose Copy path on the Overview tab to copy the S3:// link to the object.
It is possible to get the S3-URI for a proper key/file in the console, by selecting the key and clicking on the Copy path button, this will place the s3-URI for the file on the clipboard.
However, directories are not keys as such but just key prefixes, so this will not work for them.
You may fail to get s3uri if you are created a new bucket.
You can get s3uri after creating a new folder in your bucket >> select check box to the newly created folder >> then copy the s3uri that appears at the top.