Skip to content

Commit

Permalink
feat: configuration value for metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
nerg4l committed Apr 1, 2024
1 parent d4d6a4f commit bb123eb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
10 changes: 10 additions & 0 deletions config/multipart-of-madness.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 10 additions & 9 deletions src/Http/Controller/S3MultipartController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit bb123eb

Please sign in to comment.