I've got app function which uploads some rar. file straight from browser to my blob storage. This file is ~60mb. My functions uploads like 6-7kb of this file and stops (no error appears).
The goal is to upload file straight from browser because my internet connection is low and I prefer computing resources to do the job (Is my understanding good? Compute resources will do the job if uploading from browser?).
Anyway here is my code:
def download_file(link):
file = requests.get(link, stream=True)
return file.content
def get_blobclient(container=None, file_name=None):
blob_service_client = BlobServiceClient.from_connection_string(CONN)
blob_client = blob_service_client.get_blob_client(container, file_name)
return blob_client
def main(req):
logging.info('Python HTTP trigger function processed a request.')
error_message = None
params = {key:req.params.get(key) for key in ("container", "file")}
try:
if not None in params.values():
link = f'https://www21.zippyshare.com/d/{params.get("link")}'
blobClient = get_blobclient(container=params.get("container"), file_name=params.get("file"))
logging.info("Uploading file...")
blobClient.upload_blob(download_file(link), blob_type="BlockBlob")
logging.info("File has been uploaded")
return func.HttpResponse(
"File has been uploaded",
status_code=200
)
else:
error_message = f'{" ".join(str(k) for k,v in params.items() if v == None)}: These values have not been provided'
logging.info(error_message)
except Exception as error:
logging.info(error)
return func.HttpResponse(
"Something went wrong..." if error_message is None else error_message,
status_code=401
)