I can load a PDF file to shadow drive and mime type is correctly set to 'application/pdf' upon retrieval
Current Behaviour
When I fetch pdf content from file store the result cannot be displayed as the response has a text/plain mime type set and the browser is unable to render pdf binary data. I have verified the content loaded is expected data, pdf is valid, and pdf extension is set correctly when posting file. Still the pdf files do not receive the correct mime type when retrieving .
I believe this is due to ShadowFile not receiving correct mime type here: https://github.com/GenesysGo/shadow-drive-rust/blob/87643accbabaea733d918ccac93160d5739e37f2/sdk/src/models.rs#L68
Example - Reproduce
I create a temp file and post the content with the given extension
async def upload_file(self, ext, content):
temp_dir = tempfile.mkdtemp()
file_name = f"{uuid.uuid4()}.{ext}"
temp_file_path = os.path.join(temp_dir, file_name)
try:
if ext.lower() in ["pdf", "other_binary_extension"]:
async with aiofiles.open(temp_file_path, "wb") as temp_file:
# import pdb; pdb.set_trace()
await temp_file.write(content)
urls = await run_async(self.client.upload_files, [temp_file_path])
return file_name, urls[0]
else:
print("nah wtf")
finally:
# Clean up the file and the directory when done using run_async
await run_async(os.remove, temp_file_path)
await run_async(os.rmdir, temp_dir)
Validate the POSTed file from file store and writing file to local disk yields valid pdf file that was posted
data = await sdrive_client.fetch_content("bc0b026f-1f31-4255-b03f-00192ce41dfc.pdf")
async with aiofiles.open("firstaid2.pdf", "wb") as out_file:
await out_file.write(data.getvalue())
Expected Behavior:
I can load a PDF file to shadow drive and mime type is correctly set to 'application/pdf' upon retrieval
Current Behaviour
When I fetch pdf content from file store the result cannot be displayed as the response has a text/plain mime type set and the browser is unable to render pdf binary data. I have verified the content loaded is expected data, pdf is valid, and pdf extension is set correctly when posting file. Still the pdf files do not receive the correct mime type when retrieving . I believe this is due to ShadowFile not receiving correct mime type here: https://github.com/GenesysGo/shadow-drive-rust/blob/87643accbabaea733d918ccac93160d5739e37f2/sdk/src/models.rs#L68
Example - Reproduce
I create a temp file and post the content with the given extension
Validate the POSTed file from file store and writing file to local disk yields valid pdf file that was posted data = await sdrive_client.fetch_content("bc0b026f-1f31-4255-b03f-00192ce41dfc.pdf") async with aiofiles.open("firstaid2.pdf", "wb") as out_file: await out_file.write(data.getvalue())
Fetching file fails to load the pdf and response header is set to text/plain: e.g.: https://shdw-drive.genesysgo.net/H4VgQ4i666aPQ69fA2wDoYXb4qs4dSBeUm4gmP2cQhjY/bc0b026f-1f31-4255-b03f-00192ce41dfc.pdf