parse-server-s3-adapter icon indicating copy to clipboard operation
parse-server-s3-adapter copied to clipboard

Adapter does't work with ap-east-1 (HK)

Open vitalii-bulyzhyn opened this issue 4 years ago • 7 comments

There is the issue with adapter: if I'm using with it ap-east-1 (HK) region - I can upload image without problems, however when I get wrong URL to access it.

The url does not specify region. Perfectly works with other regions

vitalii-bulyzhyn avatar Jan 24 '21 21:01 vitalii-bulyzhyn

Thanks for reporting.

We need more details to analyze this. Can you give example results for working and non-working regions, to clearly describe what difference you are observing and why it is not working?

mtrezza avatar Jan 24 '21 23:01 mtrezza

This is example of URL I get when I'm uploading files to ap-east-1:

https://impacked-bucket.s3.amazonaws.com/ae4f9b42e88d85f09dec2d9ebbacb047_download.jpeg

But correct URL should be:

https://impacked-bucket.s3.ap-east-1.amazonaws.com/ae4f9b42e88d85f09dec2d9ebbacb047_download.jpeg

image

vitalii-bulyzhyn avatar Jan 25 '21 21:01 vitalii-bulyzhyn

Can you please also share your S3 adapter configuration?

mtrezza avatar Jan 26 '21 09:01 mtrezza

Yes, of course

var s3Adapter = new S3Adapter( process.env.AWS_ACCESS_KEY, process.env.AWS_SECRET_KEY, process.env.S3_BUCKET_NAME, { region: process.env.S3_REGION, directAccess: true, signatureVersion: 'v4', }, );

vitalii-bulyzhyn avatar Jan 26 '21 21:01 vitalii-bulyzhyn

How do you use the adapter in the context of Parse Server? Is the S3 adapter configuration not part of your Parse Server configuration?

filesAdapter: {
  module: "@parse/s3-files-adapter",
  options: {
      bucket: ...,
      region: ...,
      bucketPrefix: ...,
      baseUrl: ...,
      signatureVersion: "v4",
  }
},

mtrezza avatar Jan 27 '21 00:01 mtrezza

This is how it is:

var s3Adapter = new S3Adapter( process.env.AWS_ACCESS_KEY, process.env.AWS_SECRET_KEY, process.env.S3_BUCKET_NAME, { region: process.env.S3_REGION, directAccess: true, signatureVersion: 'v4', }, );

var api = new ParseServer({ databaseURI: databaseUri, cloud: process.env.CLOUD_CODE_MAIN, masterKey: process.env.MASTER_KEY, serverURL: process.env.SERVER_URL, filesAdapter: s3Adapter, });

vitalii-bulyzhyn avatar Jan 27 '21 03:01 vitalii-bulyzhyn

I would look into whether the way you initialize makes any difference. From your code it's not clear which adapter repo you are using. Either way, I suggest you take a look at the region parameter and how the URL is composed in the adapter. I would imagine the logic to be region-agnostic, but according to your description, it works for you if you change the region, so something doesn't add up.

mtrezza avatar Jan 27 '21 15:01 mtrezza