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?


Hi @sony.sadi,

Our FormData implementation does not currently handle file uploads correctly – it treats them as text. We’d like to add this functionality, but need to be careful not to break any existing scripts which don’t account for file uploads. Unfortunately, this means that it’s going to take a while before we can add the functionality.