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] Downloading files when running in sub directory #14485

Merged
merged 12 commits into from
May 20, 2019
6 changes: 5 additions & 1 deletion app/file-upload/server/methods/sendFileMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import _ from 'underscore';
import { Uploads } from '../../../models';
import { callbacks } from '../../../callbacks';
import { FileUpload } from '../lib/FileUpload';
import { settings } from '../../../settings';

Meteor.methods({
async sendFileMessage(roomId, store, file, msgData = {}) {
Expand All @@ -30,7 +31,10 @@ Meteor.methods({

Uploads.updateFileComplete(file._id, Meteor.userId(), _.omit(file, '_id'));

const fileUrl = `/file-upload/${ file._id }/${ encodeURI(file.name) }`;
const siteUrl = settings.get('Site_Url');
const prefix = siteUrl.replace(/http(s)?:\/\/[a-z]*(\.[a-z]*)*(:[0-9]*)?/g, '');

const fileUrl = `${ prefix }/file-upload/${ file._id }/${ encodeURI(file.name) }`;

const attachment = {
title: file.name,
Expand Down