Skip to content

Commit

Permalink
fix: Custom sounds not working when storage is set to filesystem (#33424
Browse files Browse the repository at this point in the history
)
  • Loading branch information
KevLehman authored Oct 11, 2024
1 parent 6ece177 commit bd5a5ff
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
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.
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

0 comments on commit bd5a5ff

Please sign in to comment.