parse-community / parse-server-s3-adapter

AWS S3 file storage adapter for Parse Server
Other
80 stars 83 forks source link

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

Open vitalii-bulyzhyn opened 3 years ago

vitalii-bulyzhyn commented 3 years ago

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

mtrezza commented 3 years ago

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?

vitalii-bulyzhyn commented 3 years ago

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

mtrezza commented 3 years ago

Can you please also share your S3 adapter configuration?

vitalii-bulyzhyn commented 3 years ago

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

mtrezza commented 3 years ago

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",
  }
},
vitalii-bulyzhyn commented 3 years ago

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

mtrezza commented 3 years ago

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.