Through form data i'm able to upload the image to azure blob storage through backend. How can i get real time image from expo camera and upload the same to azure blob storage.
Backend code- 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