通过表单数据,我可以通过后端上传图像到Azure Blob存储。我如何从世博会相机真实的图像,并上传相同的Azure Blob存储。
enter image description here
后端代码- flask python
@app.route('/api/addincident', methods=['POST'])
def upload_file(): # to upload image
file = request.files['file']
damage_type = request.form.get('damage_type')
damage_parts = request.form.get('damage_parts')
location_address = request.form.get('location_address')
geolocation_latitude = request.form.get('geolocation_latitude')
geolocation_longitude = request.form.get('geolocation_latitude')
datetime = request.form.get('datetime')
created_by = request.form.get('created_by')
created_on = request.form.get('created_on')
modified_by = request.form.get('modified_by')
modified_on = request.form.get('modified_on')
customer_id = request.form.get('customer_id')
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
image_filepath = 'http://' + account + '.blob.core.windows.net/' + container + '/' + filename
connection = database
cursor = connection.cursor()
postgres_insert_query = """INSERT INTO incidentreport(damage_type, damage_parts, location_address,
geolocation_latitude, geolocation_longitude, datetime, image_filepath, created_by, created_on, modified_by,
modified_on, customer_id)VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) """
cursor.execute(postgres_insert_query, (
damage_type, damage_parts, location_address, geolocation_latitude, geolocation_longitude, datetime,
image_filepath, created_by, created_on, modified_by, modified_on, customer_id))
connection.commit()
return image_filepath
1条答案
按热度按时间t1qtbnec1#
你可以尝试通过Power应用使用相机控件,并将图像上载到Azure Blob存储。Camera control上有一个名为Stream的属性(使用Stream、StreamRate和OnStream属性自动在计时器上捕获图像,例如每分钟拍摄一张照片以创建延时序列。)
How to upload images from the camera control to Azure blob storage