Rocket.Chat icon indicating copy to clipboard operation
Rocket.Chat copied to clipboard

S3 URL includes inner protocol for folder name.

Open maxsdw opened this issue 10 years ago • 2 comments

Your Rocket.Chat version: 0.26.0

When using S3 as file storage service, the protocol should be striped out before using it for a folder name. Currently I'm getting this when retrieving a resource inside a channel:

https://corporativeapp-testchatbucket.s3.amazonaws.com/https://testchat.corporativeapp.com/Dv...

and it should be:

https://corporativeapp-testchatbucket.s3.amazonaws.com/testchat.corporativeapp.com/Dv...

In above example "testchat.corporativeapp.com" is the folder name in the S3 bucket. This is not preventing the resource to be rendered, but it makes the URL looks wrong.

maxsdw avatar Apr 14 '16 21:04 maxsdw

This was just fixed on the develop branch. We will create a migration script but you will have to move the folder on your S3 bucket manually.

engelgabriel avatar Apr 14 '16 23:04 engelgabriel

If you want to move your file on S3, you can run the script above in your MongoDB to keep the files accessible from Rocket.Chat:

var wrongPath = 'https://demo.rocket.chat';
var rightPath = 'demo.rocket.chat';
db['rocketchat_uploads'].find({ store: 's3', 's3.path': new RegExp('^' + wrongPath.replace(/\./g, '\\.')) }).forEach(function(up) {
    if (up.url) {
        db['rocketchat_uploads'].update({ _id: up._id }, {
            $set: {
                's3.path': up.s3.path.replace(new RegExp(wrongPath, 'g'), rightPath),
                url: up.url.replace(new RegExp(wrongPath, 'g'), rightPath)
            }
        });
    }
});

sampaiodiego avatar Apr 25 '16 17:04 sampaiodiego