title: PHP Amazon S3 Uploads And Tags
body: <p>I'm coding a video sharing site. I'm using S3 to store and serve up the videos. I've coded tags for the videos in my MySQL database but I saw that S3 supports settings tags on uploaded files. Here's the code I'm using to upload files:</p>
  
  <pre><code>try {
                  //Create a S3Client
                  $s3Client = new S3Client([
                      'region' =&gt; 'us-east-1',
                      'version' =&gt; 'latest',
                      'credentials' =&gt; [
                          'key' =&gt; '',
                          'secret' =&gt; ''
                      ]
                  ]);
                  $result = $s3Client-&gt;putObject([
                      'Bucket' =&gt; $bucket,
                      'Key' =&gt; $assetFilename,
                      'SourceFile' =&gt; $fileTmpPath,
                      'Metadata'   =&gt; array(
                          'title' =&gt; $requestAr['title'],
                          'description' =&gt; $requestAr['description']
                      )
                  ]);
                  $s3Client-&gt;waitUntil('ObjectExists', array(
                      'Bucket' =&gt; $bucket,
                      'Key'    =&gt; $assetFilename
                  ));
              } catch (S3Exception $e) {
                  returnError($e-&gt;getMessage());
              }
  </code></pre>
  
  <p>This is a 2 part question. First, how can I specify tags here? I can't find any PHP examples. Next, let's say someone uploads a video and they put a tag on it. S3 tags are key/value pairs. What should I set for the keys? I was thinking of just using something like [tag1, tag2, tag3] for each video and the value of those being the tag strings. Here's the S3 tags doc: <a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/object-tagging.html" rel="nofollow noreferrer">https://docs.aws.amazon.com/AmazonS3/latest/dev/object-tagging.html</a></p>