diced / zipline

A ShareX/file upload server that is easy to use, packed with features, and with an easy setup!

Home Page:https://zipline.diced.sh/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug: Zipline does not set MIME type for files uploaded to S3

diced opened this issue · comments

Discussed in #493

Originally posted by AlexisEvo November 21, 2023
When using S3 as a datastore, zipline does not set the MIME/content type of files it uploads to S3. This means if you attempt to load the files directly from the S3 provider, it will download the file rather than showing it in browser. I'm awful at typescript, but it looks like zipline already determines the MIME, so it just needs to be added to this putObject request:

await this.s3.putObject(this.config.bucket, file, data);

My use case for this is that I've been using ShareX with Backblaze B2 for a while. B2 lets you use a custom domain name through CloudFlare and does not charge egress bandwidth for it. So I can have zipline.example.com pointing to my docker instance, and i.example.com pointing to CloudFlare which points to the B2 public bucket. ShareX gives me a link like i.example.com/u/file.jpg and it could transfer TBs of bandwidth without me being charged.

B2's S3 API can automatically determine MIME type based on file extension, so for now I've just hacked it together by changing this line to

await this.s3.putObject(this.config.bucket, file, data, { 'Content-Type': 'b2/x-auto' });

But it'd be nice if this were built in and vendor agnostic.