簡體   English   中英

如何通過 react native(expo) 將圖像上傳到 azure blob 存儲? (獲取實時圖像並上傳該圖像)

[英]How can i upload an image through react native(expo) to azure blob storage? (get real time image and upload that image)

通過表單數據,我可以通過后端將圖像上傳到 azure blob 存儲。 我如何從 expo 相機獲取實時圖像並將其上傳到 azure blob 存儲。

在此處輸入圖像描述

后端代碼- 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

您可以嘗試通過 Power Apps 使用相機控制並將圖像上傳到 Azure Blob 存儲。 Camera控件上有一個名為 Stream 的屬性(使用 Stream、StreamRate 和 OnStream 屬性自動捕獲計時器上的圖像,例如每分鍾拍攝一張照片以創建延時序列。)

如何從相機控件上傳圖片到Azure blob存儲

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM