Skip to content

Commit

Permalink
Merge pull request #43 from petrbroz/php
Browse files Browse the repository at this point in the history
Fixed file upload errors.
  • Loading branch information
augustogoncalves authored Sep 22, 2020
2 parents fe43e19 + fcc122c commit f72f8ed
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions server/oss.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public function getBucketsAndObjects(){
$bucketlist = array();
for($i=0; $i< $bucketsLength; $i++){
$cbkey = $buckets[$i]['bucketKey'];
$cbtext = ForgeConfig::$prepend_bucketkey&&strpos($cbkey, strtolower(ForgeConfig::getForgeID())) === 0? end(explode('_', $cbkey)):$cbkey;
$exploded = explode('_', $cbkey);
$cbtext = ForgeConfig::$prepend_bucketkey&&strpos($cbkey, strtolower(ForgeConfig::getForgeID())) === 0? end($exploded):$cbkey;
$bucketInfo = array('id'=>$cbkey,
'text'=> $cbtext,
'type'=>'bucket',
Expand Down Expand Up @@ -104,12 +105,13 @@ public function uploadFile(){
$fileToUpload = $file['fileToUpload'];
$filePath = $fileToUpload['tmp_name'];
$content_length = filesize($filePath);
$file_content = file_get_contents($filePath);

// $fileRead = fread($filePath, $content_length);

try {

$result = $apiInstance->uploadObject($bucket_key, $fileToUpload['name'], $content_length, fopen($filePath,'r+') );
$result = $apiInstance->uploadObject($bucket_key, $fileToUpload['name'], $content_length, $file_content);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling ObjectsApi->uploadObject: ', $e->getMessage(), PHP_EOL;
Expand Down

0 comments on commit f72f8ed

Please sign in to comment.