I am working on the S3 bucket uploads and encountered an issue.I want to update the folder name inside one of my bucket.Went through the API here,but did not find a solution.
I would like to know if it is possible to achieve it or not?I would like experts over here to give inputs on it.
Thank you for your time.
Folders are not really folders in s3. They are just parts of the object key.
To "rename" the folder, you will need to rename all the objects inside the folder to include a different folder in its path.
Related
I have to move all files and folders from one folder to another of S3 bucket in php. I know a way to do the same thing is:
Get all objects list from the source folder
Copy all objects into destination folder
Delete all objects from source folder
Then I know AWS don't have folders with some sort of hierarchy, it's only buckets based but now a days have any option or updates.
I am using Amazon S3 PHP Class version 0.4.0
Amazon S3 does not have a 'move' command. The only choice is to copy then delete.
The copy command tells S3 to copy the object, without requiring any downloads. Therefore, it is fast and efficient.
While S3 doesn't use folders, it does understand prefixes. The full path is part of the filename (Key). So, for example:
If you want to move folder1/foo.txt to folder2/foo.txt, then:
Copy folder1/foo.txt to folder2/foo.txt
Delete folder1/foo.txt
To use AWS with PHP, you should use the official AWS SDK for PHP.
I'm developing an application with Symfony2, and my users get to look at their folders (located in alfresco) but at a certain point some files need to be moved from one folder to another.
I tried ftp_rename but didn't have much luck with it. I could rename a file's name with it but I couldn't move it from one location to another.
I tried looking at the alfresco docs but didn't find anything helpful because I'm developing an api and I can't use Cmis Js.
The ftp_rename can rename/move a single file only. You cannot use it to move all files in a directory to another.
So you have to:
list all files in the source directory, e.g. using the ftp_nlist.
call the ftp_rename for each, one-by-one.
Is it possible to create a file on Dropbox via the API and write to it directly? My current solution is to create a temp file locally, write to it, upload it and then remove the temp file.
I've only been able to find references on the Dropbox documentation to uploading files and not creating files, so I assume the above isn't possible, but would love to know if anyone has found a way.
Thanks in advance!
I don't understand what distinction you're drawing between "creating files" and "uploading files." You can certainly create/upload a file via the Dropbox API. See /files_put. Since you tagged this with PHP, the relevant methods in the official PHP SDK are uploadFile and uploadFileFromString.
Please i'll like you to enlighten me how best (folder) to save uploaded user profile pictures. In my previous projects i've usually uploaded into a folder inside the main project folder i.e
www/projectFolder/upload
would this be good for efficiency and security?
Already, i've disabled folder navigation (from URL) through .htaccess
this question
upload file with php and save path to sql
prompted my question.
Thanks
Why you don't use database to save them? I guess this is the best choice.
Anyway, if you can't save them in DB for any reason & you have to save images in a directory on your filesystem, I guess it's better to save them somewhere out of your web server htdoc directory (& sub directories), so access to those files would not be possible directly via web server. of course you'll need enough permission to allow your php scripts to read, write & modify files in target directory.
Also suggest to take a look at usage of .htaccess files on apache.
I have one instance in Amazon EC2. It is a Photobook. User can signup and upload images and they can create a photobook. S for that we want S3 storage. I searched a lot for a good PHP class to manipulate these folders, images and html files.
Now I have no idea how we can create folder, delete folder and search for a folder.
Can anyone help find a solution for these folder/image manipulation requirements like create , search, delete?
The official PHP SDK?
http://aws.amazon.com/sdkforphp/
http://aws.amazon.com/php/
Good question. I was trying to do it now and didn't found the answer in any documentation.
So I discovered that you just need to send the entire path in $keyname parameter:
folder/my_file_name.jpg
The S3 service can recognize and creates automatically the folders.
I think as me, you were looking for a method create_folder-like.
Easy and tricky.