Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Custom sounds not working when storage is set to filesystem #33424

Merged
merged 7 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/seven-hotels-collect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fixes a problem with custom sounds causing files to not be playable when using filesystem storage.
KevLehman marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ Meteor.startup(() => {
} else {
res.setHeader('Last-Modified', new Date().toUTCString());
}

res.setHeader('Content-Type', file.contentType);
res.setHeader('Content-Length', file.length);

Expand Down
9 changes: 6 additions & 3 deletions apps/meteor/app/file/server/file.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import stream from 'stream';

import type { ObjectId } from 'bson';
import { MongoInternals } from 'meteor/mongo';
import mime from 'mime-type/with-db';
import mkdirp from 'mkdirp';
import type { GridFSBucketReadStream } from 'mongodb';
import { GridFSBucket } from 'mongodb';
Expand Down Expand Up @@ -166,11 +167,13 @@ class FileSystem implements IRocketChatFileStore {
const rs = this.createReadStream(fileName);
return {
readStream: rs,
// contentType: file.contentType
// We currently don't store the content type of uploaded custom sounds when using
// The filesystem storage. We will use mime to infer its type from the extension.
contentType: (mime.lookup(fileName) as string) || 'application/octet-stream',
length: stat.size,
};
} catch (error1) {
//
console.error(error1);
}
}

Expand All @@ -197,7 +200,7 @@ class FileSystem implements IRocketChatFileStore {
try {
return await this.remove(fileName);
} catch (error1) {
//
console.error(error1);
}
}
}
Expand Down
Loading