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

How to set s3ForcePathStyle in apostrophe-attachments/uploadfs for Minio #61

Open
viewdeckcloud opened this issue Dec 3, 2020 · 4 comments

Comments

@viewdeckcloud
Copy link

viewdeckcloud commented Dec 3, 2020

Hi, this is probably a newbie question, but Im struggling to see how to set the
s3ForcePathStyle option in s3.js / uploadfs to get apostrophe-attachments to use {endpoint}/{bucket} format rather than {bucket}.{endpoint} format. ( needed for Minio and Wasabi it seems )

( Following the handy guide in https://wasabi-support.zendesk.com/hc/en-us/articles/360004346871-How-do-I-use-Apostrophe-CMS-with-Wasabi- ) I tried :-

in app.js

    'apostrophe-attachments': {
      uploadfs: {
        s3ForcePathStyle: true
      }
    },

Ive also tried the "style" = "path" option , but that doesnt seem to filter down either.

Ive tried the suggestions in https://javascriptio.com/view/2800082/serving-apostrophe-cms-s3-assets-attachments-as-https version, which has the setup in..../lib/modules/apostrophe-attachments/index.js

// in ./lib/modules/apostrophe-attachments/index.js

module.exports = {
  uploadfs: {
        s3ForcePathStyle: true
  }
}

But alas, none of these have the desired outcome..
Possibly missing something very obvious, but any pointers greatly appreciated...
``

@boutell
Copy link
Member

boutell commented Dec 4, 2020

I don't think we currently support this. As I understand it AWS is deprecating path style, although it appears they have pushed that back at least another year or so for various backwards compatibility reasons. So it has never been a priority on our end. But it would make a great community contribution to uploadfs.

@boutell
Copy link
Member

boutell commented Dec 4, 2020

I don't think passing this option on is actually what you need to do though. Where does Wasabi say this is required?

@viewdeckcloud
Copy link
Author

Hi Tom, Thanks for the time.. Greatly Appreciated..
( The Wasabi Reference was just to show how to configure the s3 engine, didnt specifically 'swap' to the Path mode... )

I think its already in uploadfs s3fs ( snippet below )... I did find this guidance from Minio ( https://docs.min.io/docs/how-to-use-aws-sdk-for-javascript-with-minio-server.html ) - where the s3ForcePathStyle: true is mentioned against the underlying toolkit ( aws-sdk )

node_modules/uploadfs/lib/s3.fs

      // this is to support the knox style attribute OR AWS s3ForcePathStyle attribute
      if (options.style && (options.style === 'path')) {
        options.s3ForcePathStyle = true;
      }
      pathStyle = !!options.s3ForcePathStyle;

<more stuff>

    getUrl: function (path) {
      let url;
      noProtoEndpoint = endpoint.replace(/^https?:\/\//i, '');
      if (pathStyle) {
        url = (https ? 'https://' : 'http://') + noProtoEndpoint + '/' + bucket;
      } else {
        url = (https ? 'https://' : 'http://') + bucket + '.' + noProtoEndpoint;
      }
      return utils.addPathToUrl(self.options, url, path);
    },

Form what I can see the apostrophe-attachments sets the options, which are passed through... I just cant see why this underlying option isnt appearing..

I assume setting the options in the app.js is correct.

I will keep looking, and happy to propose a change in the apostrophe-attachments if I can find the issue ( although , rfom what I see it SHOULD work ! )
;-)
Best

@boutell
Copy link
Member

boutell commented Dec 7, 2020 via email

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

No branches or pull requests

2 participants