Spaces:
Runtime error
Runtime error
cache control
Browse files
stablediffusion-infinity/app.py
CHANGED
|
@@ -242,7 +242,7 @@ blocks.config['dev_mode'] = False
|
|
| 242 |
# return response
|
| 243 |
|
| 244 |
@app.post('/uploadfile/')
|
| 245 |
-
async def create_upload_file(background_tasks, file):
|
| 246 |
contents = await file.read()
|
| 247 |
file_size = len(contents)
|
| 248 |
if not 0 < file_size < 2E+06:
|
|
@@ -260,7 +260,7 @@ async def create_upload_file(background_tasks, file):
|
|
| 260 |
temp_file.write(contents)
|
| 261 |
temp_file.seek(0)
|
| 262 |
s3.upload_fileobj(Fileobj=temp_file, Bucket=AWS_S3_BUCKET_NAME, Key="uploads/" +
|
| 263 |
-
file.filename, ExtraArgs={"ContentType": file.content_type})
|
| 264 |
temp_file.close()
|
| 265 |
|
| 266 |
return {"url": f'https://d26smi9133w0oo.cloudfront.net/uploads/{file.filename}', "filename": file.filename}
|
|
|
|
| 242 |
# return response
|
| 243 |
|
| 244 |
@app.post('/uploadfile/')
|
| 245 |
+
async def create_upload_file(background_tasks: BackgroundTasks, file: UploadFile):
|
| 246 |
contents = await file.read()
|
| 247 |
file_size = len(contents)
|
| 248 |
if not 0 < file_size < 2E+06:
|
|
|
|
| 260 |
temp_file.write(contents)
|
| 261 |
temp_file.seek(0)
|
| 262 |
s3.upload_fileobj(Fileobj=temp_file, Bucket=AWS_S3_BUCKET_NAME, Key="uploads/" +
|
| 263 |
+
file.filename, ExtraArgs={"ContentType": file.content_type, "CacheControl": "max-age=31536000"})
|
| 264 |
temp_file.close()
|
| 265 |
|
| 266 |
return {"url": f'https://d26smi9133w0oo.cloudfront.net/uploads/{file.filename}', "filename": file.filename}
|