fix: remove content length

This commit is contained in:
bennykok 2024-08-24 23:59:40 -07:00
parent 9d6ee85402
commit 65b5b0b8c7

View File

@ -80,7 +80,7 @@ async def async_request_with_retry(method, url, disable_timeout=False, **kwargs)
if response.status != 200: if response.status != 200:
error_body = await response.text() error_body = await response.text()
logger.error(f"Request failed with status {response.status} and body {error_body}") logger.error(f"Request failed with status {response.status} and body {error_body}")
raise Exception(f"Request failed with status {response.status}") # raise Exception(f"Request failed with status {response.status}")
response.raise_for_status() response.raise_for_status()
if method.upper() == 'GET': if method.upper() == 'GET':
@ -629,7 +629,7 @@ async def upload_file_endpoint(request):
with open(file_path, 'rb') as f: with open(file_path, 'rb') as f:
headers = { headers = {
"Content-Type": file_type, "Content-Type": file_type,
"Content-Length": str(file_size) # "Content-Length": str(file_size)
} }
if content.get('include_acl') is True: if content.get('include_acl') is True:
headers["x-amz-acl"] = "public-read" headers["x-amz-acl"] = "public-read"
@ -1188,7 +1188,7 @@ async def upload_file(prompt_id, filename, subfolder=None, content_type="image/p
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)) 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)}" 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 start_time = time.time() # Start timing here
result = await async_request_with_retry("GET", target_url, disable_timeout=True) result = await async_request_with_retry("GET", target_url, disable_timeout=True)
@ -1199,7 +1199,7 @@ async def upload_file(prompt_id, filename, subfolder=None, content_type="image/p
start_time = time.time() # Start timing here start_time = time.time() # Start timing here
headers = { headers = {
"Content-Type": content_type, "Content-Type": content_type,
"Content-Length": size, # "Content-Length": size,
} }
if ok.get('include_acl') is True: if ok.get('include_acl') is True: