Skip to content

Instantly share code, notes, and snippets.

@gianfebrian
Created August 18, 2019 12:33
Show Gist options
  • Select an option

  • Save gianfebrian/b524ad5725dc0c9a7a0bd1566ec4d3ec to your computer and use it in GitHub Desktop.

Select an option

Save gianfebrian/b524ad5725dc0c9a7a0bd1566ec4d3ec to your computer and use it in GitHub Desktop.
f = request.files['file']
original_filename = f.filename
unique_filename = str(uuid.uuid4())
save_location = os.path.join(UPLOAD_FOLDER, unique_filename)
f.save(save_location)
mime = magic.from_file(save_location, mime=True)
f_info = {
'original_filename': original_filename,
'mime': mime,
'unique_filename': unique_filename
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment