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

S3 URL includes inner protocol for folder name. #2896

Closed
maxsdw opened this issue Apr 14, 2016 · 2 comments
Closed

S3 URL includes inner protocol for folder name. #2896

maxsdw opened this issue Apr 14, 2016 · 2 comments
Assignees
Milestone

Comments

@maxsdw
Copy link
Contributor

maxsdw commented Apr 14, 2016

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.

@engelgabriel
Copy link
Member

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.

@marceloschmidt marceloschmidt modified the milestones: 0.28.0, 0.27.0 Apr 18, 2016
@sampaiodiego
Copy link
Member

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)
            }
        });
    }
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants