Guest User

Untitled

a guest
Dec 15th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. # This is Python Flask code, which will be hosted in Digital Ocean Droplet
  2.  
  3. @app.route('/', methods=['POST'])
  4. def upload_file():
  5. file = request.files['file']
  6.  
  7. # Is it possible to eliminate this step???
  8. file.save('/tmp/file.ext')
  9.  
  10. session = boto3.session.Session()
  11.  
  12. client = session.client('s3',
  13. region_name='nyc3',
  14. endpoint_url='https://nyc3.digitaloceanspaces.com',
  15. aws_access_key_id='ACCESS_KEY',
  16. aws_secret_access_key='SECRET_KEY'
  17. )
  18.  
  19. client.upload_file('/tmp/file.ext', # Path to local file
  20. 'my-space', # Name of Space
  21. 'file.ext') # Name for remote file
Add Comment
Please, Sign In to add comment