Home > Net >  Flutter - S3 aws amplify
Flutter - S3 aws amplify

Time:08-26

Wondering if someone knows how to upload an image from flutter (not really relevant, javascript would be the same problem) but set the image path/name from the server side.

When I upload my image to my s3 bucket in AWS amplify, the name the client passes is taken to be put in the bucket.

I would like to change this behavior by passing the image in the api call but then on the server set the path and name.

Has anyone had any luck doing this?

Best regards

CodePudding user response:

I'm assuming you have already gone through the official documentation on uploading via flutter client which looks something like this.

 final UploadFileResult result = await Amplify.Storage.uploadFile(
        local: exampleFile,
        key: 'ExampleKey',
        onProgress: (progress) {
          print('Fraction completed: ${progress.getFractionCompleted()}');
        }
    );

here, you can change key to anything of your choice e.g.

key: 'folder1/image1.jpg'

If this is not what you want to do then you can always create a new REST endpoint on your server which accepts multipart/form-data. nodejs/express example Simple file upload to S3 using aws-sdk and Node/Express

  • Related