1234567891011121314151617181920212223242526272829 |
- def upload_file():
- if request.method == 'POST':
- file = request.files['file']
- filename = secure_filename(file.filename)
- fileextension = filename.rsplit('.',1)[1]
- Randomfilename = id_generator()
- filename = Randomfilename + '.' + fileextension
- try:
- blob_service.create_blob_from_stream(container, filename, file)
- except Exception:
- print ('Exception=' + Exception)
- pass
- ref = 'http://'+ account + '.blob.core.windows.net/' + container + '/' + filename
- return '''
- <!doctype html>
- <title>File Link</title>
- <h1>Uploaded File Link</h1>
- <p>''' + ref + '''</p>
- <img src="'''+ ref +'''">
- '''
- return '''
- <!doctype html>
- <title>Upload new File</title>
- <h1>Upload new File</h1>
- <form action="" method=post enctype=multipart/form-data>
- <p><input type=file name=file>
- <input type=submit value=Upload>
- </form>
- '''
|