fix: size
This commit is contained in:
parent
8f677e520d
commit
7a693eabc8
@ -1178,22 +1178,22 @@ async def upload_file(prompt_id, filename, subfolder=None, content_type="image/p
|
|||||||
prompt_id = quote(prompt_id)
|
prompt_id = quote(prompt_id)
|
||||||
content_type = quote(content_type)
|
content_type = quote(content_type)
|
||||||
|
|
||||||
target_url = f"{file_upload_endpoint}?file_name={filename}&run_id={prompt_id}&type={content_type}&version=v2"
|
|
||||||
|
|
||||||
start_time = time.time() # Start timing here
|
|
||||||
result = await async_request_with_retry("GET", target_url, disable_timeout=True)
|
|
||||||
end_time = time.time() # End timing after the request is complete
|
|
||||||
logger.info("Time taken for getting file upload endpoint: {:.2f} seconds".format(end_time - start_time))
|
|
||||||
ok = await result.json()
|
|
||||||
|
|
||||||
start_time = time.time() # Start timing here
|
|
||||||
|
|
||||||
async with aiofiles.open(file, 'rb') as f:
|
async with aiofiles.open(file, 'rb') as f:
|
||||||
data = await f.read()
|
data = await f.read()
|
||||||
|
size = str(len(data))
|
||||||
|
target_url = f"{file_upload_endpoint}?file_name={filename}&run_id={prompt_id}&type={content_type}&version=v2&size={quote(size)}"
|
||||||
|
|
||||||
|
start_time = time.time() # Start timing here
|
||||||
|
result = await async_request_with_retry("GET", target_url, disable_timeout=True)
|
||||||
|
end_time = time.time() # End timing after the request is complete
|
||||||
|
logger.info("Time taken for getting file upload endpoint: {:.2f} seconds".format(end_time - start_time))
|
||||||
|
ok = await result.json()
|
||||||
|
|
||||||
|
start_time = time.time() # Start timing here
|
||||||
headers = {
|
headers = {
|
||||||
# "x-amz-acl": "public-read",
|
# "x-amz-acl": "public-read",
|
||||||
"Content-Type": content_type,
|
"Content-Type": content_type,
|
||||||
"Content-Length": str(len(data)),
|
"Content-Length": size,
|
||||||
}
|
}
|
||||||
# response = requests.put(ok.get("url"), headers=headers, data=data)
|
# response = requests.put(ok.get("url"), headers=headers, data=data)
|
||||||
response = await async_request_with_retry('PUT', ok.get("url"), headers=headers, data=data)
|
response = await async_request_with_retry('PUT', ok.get("url"), headers=headers, data=data)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user