export async function s3Upload(file) { // Change Date.now() if the app is heavily used const filename = `${Date.now()}-${file.name}`; const stored = await Storage.vault.put(filename, file, { contentType: file.type }); return stored.key; }
async componentDidMount() { try { let attachmentURL; const data = await this.getNote(); const note = data.Item; const { content, attachment } = note; if (attachment) { attachmentURL = await Storage.vault.get(attachment); } this.setState({ note, content, attachmentURL }); } catch (e) { console.log(e); } }