From 54c8a5cf3085644038f3f32a5a9150e11ddf7fe5 Mon Sep 17 00:00:00 2001 From: Ali Spittel Date: Sun, 5 May 2024 21:46:35 -0600 Subject: [PATCH] fix storage typos --- .../storage/set-up-storage/index.mdx | 48 +++++++++---------- .../storage/upload-files/index.mdx | 42 ++++++++-------- 2 files changed, 46 insertions(+), 44 deletions(-) diff --git a/src/pages/[platform]/build-a-backend/storage/set-up-storage/index.mdx b/src/pages/[platform]/build-a-backend/storage/set-up-storage/index.mdx index 95e853f7306..92c25a09110 100644 --- a/src/pages/[platform]/build-a-backend/storage/set-up-storage/index.mdx +++ b/src/pages/[platform]/build-a-backend/storage/set-up-storage/index.mdx @@ -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 ( -
- - -
- ); + const [file, setFile] = React.useState(); + + const handleChange = (event: any) => { + setFile(event.target.files[0]); + }; + + return ( +
+ + +
+ ); } ``` @@ -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); } diff --git a/src/pages/[platform]/build-a-backend/storage/upload-files/index.mdx b/src/pages/[platform]/build-a-backend/storage/upload-files/index.mdx index a0b53b88bc4..03fec693823 100644 --- a/src/pages/[platform]/build-a-backend/storage/upload-files/index.mdx +++ b/src/pages/[platform]/build-a-backend/storage/upload-files/index.mdx @@ -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); + } } ```