Skip to content

Commit

Permalink
fix storage typos
Browse files Browse the repository at this point in the history
  • Loading branch information
aspittel committed May 6, 2024
1 parent 7fbdf3c commit 54c8a5c
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -492,27 +492,27 @@ import React from 'react';
import { uploadData } from 'aws-amplify/storage';
function App() {
const [file, setFile] = React.useState();
const handleChange = (event: any) => {
setFile(event.target.files[0]);
};
return (
<div>
<input type="file" onChange={handleChange} />
<button
onClick={() =>
uploadData({
path: `picture-submissions/${file.name}`,
data: file,
})
}
>
Upload
</button>
</div>
);
const [file, setFile] = React.useState();
const handleChange = (event: any) => {
setFile(event.target.files[0]);
};
return (
<div>
<input type="file" onChange={handleChange} />
<button
onClick={() =>
uploadData({
path: `picture-submissions/${file.name}`,
data: file,
})
}
>
Upload
</button>
</div>
);
}
```
</InlineFilter>
Expand All @@ -532,9 +532,9 @@ upload.addEventListener("click", () => {
console.log("Complete File read successfully!", event.target.result);
try {
await uploadData({
data: event.target.result,
path: `picture-submissions/${file.files[0].name}`
});
data: event.target.result,
path: `picture-submissions/${file.files[0].name}`
});
} catch (e) {
console.log("error", e);
}
Expand Down
42 changes: 22 additions & 20 deletions src/pages/[platform]/build-a-backend/storage/upload-files/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -706,26 +706,28 @@ Monitor progress of upload by using the `onProgress` options
```javascript
import { uploadData } from 'aws-amplify/storage';

try {
const result = uploadData({
path: "album/2024/1.jpg",
// Alternatively, path: ({identityId}) => `album/{identityId}/1.jpg`
data: file,
options: {
onProgress: ({ transferredBytes, totalBytes }) => {
if (totalBytes) {
console.log(
`Upload progress ${
Math.round((transferredBytes / totalBytes) * 100)
} %`
);
}
}
}
}).result;
console.log('Path from Response: ', result.path);
} catch (error) {
console.log('Error : ', error);
const monitorUpload = async () => {
try {
const result = await uploadData({
path: "album/2024/1.jpg",
// Alternatively, path: ({identityId}) => `album/{identityId}/1.jpg`
data: file,
options: {
onProgress: ({ transferredBytes, totalBytes }) => {
if (totalBytes) {
console.log(
`Upload progress ${Math.round(
(transferredBytes / totalBytes) * 100
)} %`
);
}
},
},
}).result;
console.log("Path from Response: ", result.path);
} catch (error) {
console.log("Error : ", error);
}
}
```
</InlineFilter>
Expand Down

0 comments on commit 54c8a5c

Please sign in to comment.