So I want to be able to upload text files to S3 but I am having issues. S3
will not compress to files when they are requested so you have to do this
before you upload the file to S3. This is how I am doing it:
$destinationFilename = "buckes_name/style.css";
$sourceFilename = '/file/I/am/uploading.css';
$fileContents = gzcompress(file_get_contents($sourceFilename), 9);
$meta = array(
Zend_Service_Amazon_S3::S3_ACL_HEADER =>
Zend_Service_Amazon_S3::S3_ACL_PUBLIC_READ,
Zend_Service_Amazon_S3::S3_CONTENT_TYPE_HEADER => 'text/css',
'Content-Encoding' => 'gzip'
);
$s3 = new Zend_Service_Amazon_S3($my_aws_key, $my_aws_secret_key);
$s3->putObject( $destinationFilename, $fileContents, $meta);
print_r($meta);
print_r($s3->getInfo($destinationFilename));
Here is the print_r output:
(
[x-amz-acl] => public-read
[Content-Type] => text/css
[Content-Encoding] => gzip
)
Array
(
[type] => text/css
[size] => 807
[mtime] => 1259955606
[etag] => "0520f0a0a08a68dc7d9ada87fcdd6bb8"
)
The thing is that when I try to download the file with my browser (Firefox)
it wants to download the file rather than display it. So basically, the
browser does not decompress the gzip archive. It should be possible to do
this, but I don't see how to do it with Zend_Service_Amazon_S3. Has anyone
done this successfully?
Thanks
Mark
--
Have fun or die trying - but try not to actually die.