diff --git a/__test__/RNS3.test.js b/__test__/RNS3.test.js
index 22fc9fb0..87688906 100644
--- a/__test__/RNS3.test.js
+++ b/__test__/RNS3.test.js
@@ -57,7 +57,7 @@ describe('RNS3.put', () => {
const requestCreateMock = Request.create.mock
expect(requestCreateMock.calls.length).toBe(1)
- expect(requestCreateMock.calls[0][0]).toBe('https://my-s3-bucket.s3.amazonaws.com')
+ expect(requestCreateMock.calls[0][0]).toBe('https://s3.amazonaws.com/my-s3-bucket')
expect(requestCreateMock.calls[0][1]).toBe('POST')
expect(requestCreateMock.calls[0][2]).toBe(policy)
@@ -95,7 +95,7 @@ describe('RNS3.put', () => {
const requestCreateMock = Request.create.mock
expect(requestCreateMock.calls.length).toBe(1)
- expect(requestCreateMock.calls[0][0]).toBe('https://my-s3-bucket.s3.amazonaws.com')
+ expect(requestCreateMock.calls[0][0]).toBe('https://s3.amazonaws.com/my-s3-bucket')
expect(requestCreateMock.calls[0][1]).toBe('POST')
expect(requestCreateMock.calls[0][2]).toBe(policy)
@@ -134,7 +134,7 @@ describe('RNS3.put', () => {
const requestCreateMock = Request.create.mock
expect(requestCreateMock.calls.length).toBe(1)
- expect(requestCreateMock.calls[0][0]).toBe('https://my-s3-bucket.s3.us-east-2.amazonaws.com')
+ expect(requestCreateMock.calls[0][0]).toBe('https://s3.us-east-2.amazonaws.com/my-s3-bucket')
expect(requestCreateMock.calls[0][1]).toBe('POST')
expect(requestCreateMock.calls[0][2]).toBe(policy)
@@ -146,7 +146,7 @@ describe('RNS3.put', () => {
})
describe('parsing the XML response', () => {
- const XML_RESPONSE = '\nhttps://my-s3-bucket.s3.amazonaws.com/uploads%2Fimage.jpgmy-s3-bucketuploads/image.jpg"afba579120c3ed942f55c8ca50fe39fc"'
+ const XML_RESPONSE = '\nhttps://s3.amazonaws.com/my-s3-bucket/uploads%2Fimage.jpgmy-s3-bucketuploads/image.jpg"afba579120c3ed942f55c8ca50fe39fc"'
const response = {
status: 201,
text: XML_RESPONSE,
@@ -173,7 +173,7 @@ describe('RNS3.put', () => {
expect(result).toHaveProperty('body.postResponse.key', 'uploads/image.jpg')
expect(result).toHaveProperty('body.postResponse.etag', 'afba579120c3ed942f55c8ca50fe39fc')
expect(result).toHaveProperty('body.postResponse.bucket', 'my-s3-bucket')
- expect(result).toHaveProperty('body.postResponse.location', 'https://my-s3-bucket.s3.amazonaws.com/uploads%2Fimage.jpg')
+ expect(result).toHaveProperty('body.postResponse.location', 'https://s3.amazonaws.com/my-s3-bucket/uploads%2Fimage.jpg')
const s3PolicyGenerateMock = S3Policy.generate.mock
expect(s3PolicyGenerateMock.calls.length).toBe(1)
@@ -187,7 +187,7 @@ describe('RNS3.put', () => {
const requestCreateMock = Request.create.mock
expect(requestCreateMock.calls.length).toBe(1)
- expect(requestCreateMock.calls[0][0]).toBe('https://my-s3-bucket.s3.amazonaws.com')
+ expect(requestCreateMock.calls[0][0]).toBe('https://s3.amazonaws.com/my-s3-bucket')
expect(requestCreateMock.calls[0][1]).toBe('POST')
expect(requestCreateMock.calls[0][2]).toBe(policy)
diff --git a/src/RNS3.js b/src/RNS3.js
index de17e04f..aa1c9226 100644
--- a/src/RNS3.js
+++ b/src/RNS3.js
@@ -38,7 +38,7 @@ export class RNS3 {
contentType: file.type
}
- const url = `https://${options.bucket}.${options.awsUrl || AWS_DEFAULT_S3_HOST}`
+ const url = `https://${options.awsUrl || AWS_DEFAULT_S3_HOST}/${options.bucket}`
const method = "POST"
const policy = S3Policy.generate(options)