title: Ensuring random key names in S3 while maintaining original file names by user
body: <p>Previously, I stored client files locally, on a server using PHP (and running Apache). They would upload files, and each one would be given a randomized string ending in a pdf / jpg file extension. The original file name would be kept in a database along with the randomized name to link them back together when the user wanted the file.</p>
  
  <p>I wanted to transition to storing files on a private bucket in S3. The first thing I'm seeing is this <a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html" rel="nofollow noreferrer">article</a> which says to give Object keys a unique name, but all the examples I'm seeing just put the user's file name in there.</p>
  
  <p>This is an issue because if a user stores <code>test.pdf</code> and another, entirely different user uploads <code>test.pdf</code>, then it won't be uploaded. Another issue is if I use the random file names like I have previously been doing, and then the user gets the file from a pre-signed request, then they will be accessing a file named via some random string and not the file they thought they uploaded.</p>
  
  <p>What should I be doing to separate out a user's files, while keeping the original file name on s3?</p>