I have to move all files and folders from one folder or another of S3 bucket in php. I know a way to do the same thing is –
1) get all objects list from the source folder
2) copy all objects into destination folder
3) delete all objects from source folder
Is there any other short way to do the same. If so then please share with me, It would be appreciated, Thanks in advance
Is there any other short way to do the same
There is no short way to do this.
Here is the reason:
The concept of folders is unique to the console. Amazon S3 uses buckets and objects, but the service does not natively support folders, nor does it provide any API to work with folders.
To help you organize your data, however, the Amazon S3 console supports the concept of folders. […]
In Amazon S3, you create buckets and store objects. The service does not support any hierarchy that you see in a typical file system.
The console uses the object key names to derive the folder hierarchy. It uses the “/” character in the key name to infer hierarchy
“Moving” files to another “folder,” in S3, cannot be done, in reality. It can only be emulated, by making copies of each individual object, giving each object a new key name to the new “hierarchy,” then deleting the original. S3 does not even support renaming an individual object. Renaming is also accomplished by making a copy with the new name, then removing the original. The console gives the appearance of supporting these operations, but it actually only emulates them, as described above. This is a deliberate part of the design of S3.