Allows for object parameters be set on text upload (#55)

The default ContentType is 'application/octet-stream' which forces files to be downloaded instead of opened by the browser. 
Setting the ContentType to match the file mime type takes care of it.

//Example
$my_space->upload( 'world', "hello.txt", "public", array('ContentType' => 'text/plain'));
$my_space->upload( $imageBlob, "happy.jpg", "public", array('ContentType' => 'image/jpeg'));

//Other Uses
array('CacheControl' => 'max-age=60', 'ContentEncoding' => 'gzip');

//Source
https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html
This commit is contained in:
Miro 2021-08-04 14:09:07 -04:00 committed by GitHub
parent 39063d7831
commit 627ce8a867
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -150,10 +150,10 @@ class Space {
/*
Uploads text.
*/
function upload($text, $saveAs, $privacy = "private") {
function upload($text, $saveAs, $privacy = "private", $params = array()) {
if($privacy == "public") { $privacy = "public-read"; }
return SpacesResult($this->s3->upload($this->name, $saveAs, $text, $privacy));
return SpacesResult($this->s3->upload($this->name, $saveAs, $text, $privacy, array( 'params' => $params)));
}