diff --git a/config/multipart-of-madness.php b/config/multipart-of-madness.php index 68b525e..590e372 100644 --- a/config/multipart-of-madness.php +++ b/config/multipart-of-madness.php @@ -20,6 +20,16 @@ 'storage_disk' => env('MULTIPART_OF_MADNESS_DISK', 's3'), + /* + | + | Some providers does not allow signed urls with additional metadata. + | By toggling this value, you can enable or disable of adding them + | to the signed URL. + | + */ + + 'allow_metadata' => false, + /* |-------------------------------------------------------------------------- | Default ACL diff --git a/src/Http/Controller/S3MultipartController.php b/src/Http/Controller/S3MultipartController.php index abe5225..cddf919 100644 --- a/src/Http/Controller/S3MultipartController.php +++ b/src/Http/Controller/S3MultipartController.php @@ -46,11 +46,11 @@ public function uploadParameters(Request $request) 'metadata' => [new S3MetadataRule], ]); - $params = [ - 'ContentType' => $data['type'], - // TODO: find out why metadata addition is failing, - // 'Metadata' => $this->encodeMetadata($data['metadata']), - ]; + $params = ['ContentType' => $data['type']]; + + if (config('multipart-of-madness.allow_metadata')) { + $params['Metadata'] = $this->encodeMetadata($data['metadata']); + } if ($acl = config('multipart-of-madness.acl')) { $params['ACL'] = $acl; @@ -93,10 +93,11 @@ public function create(Request $request) $key = implode('-', [Str::random(), $data['filename']]); - $params = [ - 'ContentType' => $data['type'], - 'Metadata' => $this->encodeMetadata($data['metadata']), - ]; + $params = ['ContentType' => $data['type']]; + + if (config('multipart-of-madness.allow_metadata')) { + $params['Metadata'] = $this->encodeMetadata($data['metadata']); + } if ($acl = config('multipart-of-madness.acl')) { $params['ACL'] = $acl;