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

Delete s3 file when delete note #3

wants to merge 1 commit into
base: master
Changes from all commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+21 −2
Diff settings


Just for now

@@ -6,7 +6,7 @@ import {
} from 'react-bootstrap';
import LoaderButton from '../components/LoaderButton';
import { invokeApig, s3Upload } from '../libs/awsLib';
import { invokeApig, s3Upload, s3Delete } from '../libs/awsLib';
import config from '../config.js';
import './Notes.css';

@@ -110,7 +110,7 @@ class Notes extends Component {
handleDelete = async (event) => {

const confirmed = window.confirm('Are you sure you want to delete this note?');
const confirmed = confirm('Are you sure you want to delete this note?');

if ( ! confirmed) {
@@ -119,6 +119,12 @@ class Notes extends Component {
this.setState({ isDeleting: true });

try {
if(this.state.note.attachment) {
const s3File = this.state.note.attachment.match(/(?:.*?\/){3}(.*)/);

s3Delete(unescape(s3File[1]), this.props.userToken);

await this.deleteNote();
@@ -58,3 +58,16 @@ export async function s3Upload(file, userToken) {
ACL: 'public-read',

export async function s3Delete(filename, userToken) {
await getAwsCredentials(userToken);

const s3 = new AWS.S3();

return s3.deleteObject(

This comment has been minimized.

Copy link

QuantumInformation Oct 9, 2017

I think this should be handled on the server side

Bucket: config.s3.BUCKET,
Key: filename

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.