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

fix(js): add storage callout to encode copy source URI #8085

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,25 @@ const copyFile = async () => {
try {
const response = await copy({
source: {
path: 'album/2024/1.jpg',
// Alternatively, path: ({identityId}) => `album/{identityId}/1.jpg`
path: `album/2024/${encodeURIComponent('#1.jpg')}`,
// Alternatively, path: ({identityId}) => `album/${identityId}/${encodeURIComponent('#1.jpg')`
},
destination: {
path: 'shared/2024/1.jpg',
// Alternatively, path: ({identityId}) => `shared/{identityId}/1.jpg`
path: 'shared/2024/#1.jpg',
// Alternatively, path: ({identityId}) => `shared/${identityId}/#1.jpg`
},
});
} catch (error) {
console.error('Error', err);
}
};
```
<Callout>

The operation can fail if there's a special character in the `source` path. You should URI encode the source
path with special character. You **don't** need to encode the `destination` path.

</Callout>

<Callout>

Expand Down Expand Up @@ -106,7 +112,7 @@ In order to copy to or from a bucket other than your default, both source and de

Option | Type | Default | Description |
| -- | :--: | :--: | ----------- |
| path | string \| <br/>(\{ identityId \}) => string | Required | A string or callback that represents the path in source and destination bucket to copy the object to or from |
| path | string \| <br/>(\{ identityId \}) => string | Required | A string or callback that represents the path in source and destination bucket to copy the object to or from. <br /> **Each segment of the path in `source` must by URI encoded.** |
| bucket | string \| <br />\{ bucketName: string;<br/> region: string; \} | Default bucket and region from Amplify configuration | A string representing the target bucket's assigned name in Amplify Backend or an object specifying the bucket name and region from the console.<br/><br/>Read more at [Configure additional storage buckets](/[platform]/build-a-backend/storage/set-up-storage/#configure-additional-storage-buckets). |

</InlineFilter>
Expand Down