Uploading in MinIO
I encountered some issues when using MinIO. Here I'll document them.
Uploading Files
Before today (2024-08-13), when uploading files to the MinIO service (version: RELEASE.2022-06-11T19-55-32Z) provided by my company, I was using File objects.
Note: All my uploads were done through a JSSDK method provided by the company. I'm not sure if there's any special handling in there, but both File and Blob objects could be uploaded normally.
Everything was working fine.
But for special reasons, I compressed the files on the frontend, so the uploaded file type changed to Blob objects. (Before discovering the issue, since uploads were working fine and could be previewed, I didn't notice the problem that would follow)
By the way, about frontend compression, since I needed to compress images, I searched for plugins and eventually chose Browser Image Compression, which I think is pretty good so far.
After Uploading
After uploading, I discovered an issue: the uploaded file in MinIO didn't have a file extension. Although it could be previewed/downloaded, it didn't have a file extension (it did before), which could be problematic in certain scenarios.
So I investigated.
Initially, I thought it was an issue with the compression plugin I was using: it might have lost the file type information.
But when I checked the documentation, I found that it does preserve file type information: when fileType is not specified, it determines the file type based on the file's MIME type.
For example:
{
lastModified: 1723529024502,
name: "bird-8785666.jpg",
size: 1011406,
type: "image/jpeg"
}But after uploading to MinIO, the file extension was missing from the filename.
So I compared the file types before and after the file extension loss: File and Blob.
Then I tried uploading this File => Blob => File object: I found that the uploaded file had the file extension.
I looked at the MinIO documentation, but didn't find specific information/reasons for "why Blob object uploads lose file extensions". I might need to set up my own MinIO service and debug to find out.
But I also tried, when uploading File objects:
- Changed the filename to one without an extension, and found that the uploaded filename also didn't have an extension.
- Changed the file extension to a non-actual file type, and found that the uploaded filename's extension was also this non-actual file type. For example, if the actual filename is
bird-8785666.jpg, I changed it tobird-8785666.png, and the uploaded filename becamebird-8785666.png.
So based on the current setup, this MinIO service reads the extension from the File's fileName property as the file extension when storing.
But if you upload a Blob object, it will never have a file extension. Although the Blob object's type property does have the file type.
I'll just document this for now, and investigate further when I have the chance.