From f2002bb6b688cec9dc6a51b0c5edebb5e21edd03 Mon Sep 17 00:00:00 2001 From: mirohristov-com Date: Thu, 17 Dec 2020 13:18:19 -0500 Subject: [PATCH] Allows for object parameters be set on text upload 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 --- spaces.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spaces.php b/spaces.php index f94358d..63f81ae 100644 --- a/spaces.php +++ b/spaces.php @@ -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))); }