Creating a folder via s3cmd (Amazon S3)

社会主义新天地 提交于 2019-11-29 05:36:16

问题


I am using s3cmd to upload files to my S3 server. My problem is that when a directory on the server does not exist the upload fails. How can I tell s3cmd to create the folder if it does not exist? I am using PHP.


回答1:


I believe you should try something like s3cmd put file.jpg s3://bucket/folder/file.jpg.

S3 doesn't have the concept of directories, the whole folder/file.jpg is the file name. If using a GUI tool or something you delete the file.jpg from inside the folder, you will most probably see that the folder is gone too. The visual representation in terms of directories is for user convenience.




回答2:


If you don't want to upload a file, you can copy the special $folder$ object that s3 tools create to mark folders:

s3cmd cp 's3://bucket/parent_$folder$' 's3://bucket/parent/child_$folder$'

which creates a "child" "folder".

It's less confusing to upload something in the child location instead:

s3cmd put dummy s3://bucket/parent/child/dummy

Hive seems to require that the full S3 path exist when creating an external table. That's why I am looking at this question :)




回答3:


This is how to create a folder s3cmd put foobar s3://bucket_name/new_directory/

to verify - s3cmd la



来源:https://stackoverflow.com/questions/6553361/creating-a-folder-via-s3cmd-amazon-s3

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!