[Extension] es3

Since there were questions about CDN and S3 I thought I would share this extension that I made some time ago. I really only built out the pieces that applied to what I needed, so it’s a pretty basic adaptation.

Happy to answer any questions or look at expanding functionality if needed.

Hope someone finds it helpful!

es3 extension

  • Dana

Hi Dana, thanks for this wrapper - works well and much appreciated!

I have two questions though - perhaps you can help (there’s always more questions :)

[list=1]

[*]Can you provide an example of how to access the other functions in the S3 class? (I’m missing something there)

[*]Do you know any way to delete an entire S3 folder? (I’m storing user images in custom folders and want to be able to delete this folder when a user is deleted)

[/list]

Any help greatly appreciated!

/Rob

Further to my second question, I did find a way to delete all images in an S3 folder, but I had to use the Amazon S3 PHP SDK class that includes a method called ‘list_objects’.

This method supports a ‘prefix’ option that allows you to filter all objects by a particular folder (matching the prefix) and then once you have this subset, you can delete the individual files using ‘delete_object’.

So I got it working in the end!

I’m glad you got it figured out. :)

To access one of the existing S3 methods from the ES3 component, you’d simply use the call method to reference the method name:





$buckets = $myS3->call( 'listBuckets' );




It’s not meant to give a great deal of access to the s3 account, so it will not work with anything very complex.

Thanks Dana, I see how it works now. BTW, thanks for sharing your extension- it has helped me learn a lot about wrappers for APIs!

Hey Dana,

i have an error which says that the bucket does not exist, even thought it is, do you know maybe why?

Thanks,

Yuval

Can you post how you are attempting to access the bucket? Amazon can be fairly picky about the structure of the bucket names and where/how you place your directory separators in accessing content.

Also, if you run the list buckets command, do you see the list that you expect, including the bucket you’re trying to access?