1

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

blue pine
  • 472
  • 6
  • 17
Pouissante
  • 56
  • 1
  • 5
  • 25

1 Answers1

1

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

Anurag
  • 134
  • 6
  • Correct, I have gone through the example. This shows that it is set on the client side. I would like to be able to edit the image name and path that is set on the client before it hits my s3 bucket. The client side isn't safe and I would like to edit the filename on the serverside to have control of what is stored. – Pouissante Aug 24 '22 at 07:46
  • Okay then part 2 of my answer is the way you want to go. Have an API created which can take binary and then name the key of your choice which will ultimately put it in s3. – Anurag Aug 25 '22 at 08:20