Question

I'd like to store my asset in the cloud. I thought Zend_Cloud_Storage may be the right library? For now they are saved locally using Zend_Cloud_StorageService_Adapter_Filesystem. Upload works so far.

What is the right way to send files from Zend_Cloud_StorageService_Adapter_Filesystem to the browser? I guess this is only possible by streaming them through php? If yes any code examples out there because I have problems getting it working with all the file header.

Using S3 I probably would make a redirect or directly link the files to the s3 bucket?

I'm pretty new to cloud storage so I really appreciate your help.

Kind regards, Manuel

Was it helpful?

Solution

The Zend Cloud services are fairly new and from my experience the documentation still needs a bit of work. Depending on the cloud service, you have either the choice of fetching your objects and delivering them to the user or in some cases you can give the user a direct URL to the asset (this largely depends on if you need to control access to the object).

To fetch an item programmatically, you should be able to get it to work with right header, for example:

$image = $storage->fetchItem("/my/remote/path/picture.jpg");
header("content-type: image/jpg");
echo file_get_contents($image);

In theory you can get the content type for the header from the metadata, but I'm not sure if it is consistent between adapters.

Linking directly depends on your Cloud. For the filesystem you should know the path to where your files are, so you can link from there if they are accessible. In Amazon, you can set the permissions to public when you upload the file - there is an example in the S3 doco here.

I'd recommend having a look at the Zend Service S3 doco, Zend Cloud is just a wrapper for it and in trying to be generic it looses a lot of functionality. if you work with it for any length of time I suspect you'll eventually end up doing calls straight to the service.

Good luck!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top