How to get the file name?


I am sending file to CFW and cfw will send it to S3.

    let data = new FormData();
    data.append("somekey", "somevalue");
    data.append("image", document.getElementById("image").files[0]);
        .put("" , data, config) // is my worker route.

In my workers I want to retrieve the file name and send it to s3 like this

    var spacesEndpoint = new AWS.Endpoint("");
    var s3 = new AWS.S3({
      endpoint: spacesEndpoint,
      accessKeyId: accessKeyId,
      secretAccessKey: secretAccessKey,
      params: { Bucket: "xyz" }

    const postData = await r.formData(); //r = request

    var file = postData.get("image");
    var fileName =postData.get("image").name;
    let type =postData.get("image").type ;

        Key: fileName,
        Body: file,
        ACL: "public-read",
        ContentType: type
      function(err, data) {
        if (err) {

it’s not working how can I do it?