0

I'm wanting to access the custom metadata for an object uploaded via the S3 multipart upload after firing off the completeMultipartUpload method.


I initiate a multipart S3 upload with some added custom metadata like so:

$response = $this->client->createMultipartUpload([
    'Bucket'        => $this->bucket,
    'Key'           => $key,
    'ContentType'   => $type,
    'Expires'       => 60,
    'Metadata'   => [
        'file-guid' => $fileGuid,
    ],
]);

When I complete the multipart upload, I'm wanting to access the file-guid metadata and pass it along in my response.

$result = $this->client->completeMultipartUpload([
    'Bucket'          => $this->bucket,
    'Key'             => $key,
    'UploadId'        => $uploadId,
    'MultipartUpload' => [
        'Parts' => $parts,
    ],
]);

$fileGuid = $result['?'] // Couldn't find the metadata in the result.

return response()->json(['file-guid' => $fileGuid]);

I've checked the S3 object after it's been uploaded and it shows the custom metadata, but I don't see how to access it. I assumed it would be part of the completeMultipartUpload response, but I'm not seeing it.

enter image description here

Any help would be appreciated. Thanks!

Josh
  • 714
  • 2
  • 8
  • 20

1 Answers1

0

I found a solution, but it involves an additional request. If anyone knows of a way to access the metadata without making another request, that would be better.

$headObject = $this->client->headObject([
    'Bucket' => $this->bucket,
    'Key' => $key,
]);
Josh
  • 714
  • 2
  • 8
  • 20