The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/app/file-upload/server/methods/getS3FileUrl.js

22 lines
597 B

import { Meteor } from 'meteor/meteor';
import { UploadFS } from 'meteor/jalik:ufs';
import { settings } from '../../../settings';
import { Uploads } from '../../../models';
let protectedFiles;
settings.get('FileUpload_ProtectFiles', function(key, value) {
protectedFiles = value;
});
Meteor.methods({
getS3FileUrl(fileId) {
if (protectedFiles && !Meteor.userId()) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'sendFileMessage' });
}
const file = Uploads.findOneById(fileId);
return UploadFS.getStore('AmazonS3:Uploads').getRedirectURL(file);
},
});