title: python AWS boto3 create presigned url for file upload
body: <p>I'm writing a django backend for an application in which the client will upload a video file to s3. I want to use presigned urls, so the django server will sign a url and pass it back to the client, who will then upload their video to s3. The problem is, the generate_presigned_url method does not seem to know about the s3 client upload_file method...</p>
  
  <p>Following this <a href="https://boto3.amazonaws.com/v1/documentation/api/latest/guide/s3-presigned-urls.html" rel="nofollow noreferrer">example</a>, I use the following code to generate the url for upload:</p>
  
  <pre><code>s3_client = boto3.client('s3')
  try:
      s3_object_name = str(uuid4()) + file_extension
      params = {
          "file_name": local_filename,
          "bucket": settings.VIDEO_UPLOAD_BUCKET_NAME,
          "object_name": s3_object_name,
      }
      response = s3_client.generate_presigned_url(ClientMethod="upload_file",
                                                  Params=params,
                                                  ExpiresIn=500)
  except ClientError as e:
      logging.error(e)
      return HttpResponse(503, reason="Could not retrieve upload url.")
  </code></pre>
  
  <p>When running it I get the error:</p>
  
  <blockquote>
    <p>File "/Users/bridgedudley/.local/share/virtualenvs/ShoMe/lib/python3.6/site-packages/botocore/signers.py", line 574, in generate_presigned_url
        operation_name = self._PY_TO_OP_NAME[client_method]
    KeyError: 'upload_file'</p>
  </blockquote>
  
  <p>which triggers the exception:</p>
  
  <blockquote>
    <p>botocore.exceptions.UnknownClientMethodError: Client does not have method: upload_file</p>
  </blockquote>
  
  <p>Afer debugging I found that the self._PY_TO_OP_NAME dictionary only contains a subset of the s3 client commands offered <a href="https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#client" rel="nofollow noreferrer">here</a>:
  <a href="https://i.stack.imgur.com/TRIz6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TRIz6.png" alt="enter image description here"></a></p>
  
  <p>scrolling down to "upload"...
  <a href="https://i.stack.imgur.com/ayqz6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ayqz6.png" alt="enter image description here"></a></p>
  
  <p>No upload_file method! I tried the same code using "list_buckets" and it worked perfectly, giving me a presigned url that listed the buckets under the signer's credentials.</p>
  
  <p>So without the upload_file method available in the generate_presigned_url function, how can I achieve my desired functionality?</p>
  
  <p>Thanks!</p>