Unable to create temporary file in custom app

In Deal : I’m trying to upload file using create file api from get amazon s3 file. So, I’m get that file and download in local using fs.createWriteStream( ), and then I sending to creatFile api, After that I romved that local file usnig fs.unlink( ). In locally it’s working fine. fdk validate also not trows any warn message.In custom app, it’s not accepts fs.createWriteStream( ).

Apps do not get filesystem access. You can try to stream the content of the file directly to the endpoint for uploading it, instead of writing it to the disk. The exact approach depends on the detail of the use case.

Hi @kaustavdm Thanks for your reply,

I’m getting files from Amzon s3 below formats.

let filePath = s3.getObject({Bucket: "Bucket_name",Key: "s3_access_key"}).createReadStream();

or

let filePath = fs.createReadStream(s3.getObject({Bucket: "Bucket_name",Key: "s3_access_key"}))

But API doesn’t allows these two formats.

let args = {
    file: {
      value: filePath,
      options: {
        filename: null,
        contentType: null,
      },
    },
    file_name: targetable_id,
    is_shared: "true",
    targetable_id: targetable_id,
    targetable_type: "Deal",
  };

  const optionsParams = {
    method: "POST",
    url: "https://agiratech.myfreshworks.com/crm/sales/api/documents",
    headers: {
      Authorization: "Token token= my_token",
      "Content-Type": "multipart/form-data",
    },
    formData: args,
  };

  request(optionsParams, function (error) {
      console.log("create file API error :", error);
  });

HI @Freshworks volunteers and community users: cud you please anyone know about this topic please reply me or my mail (mohamed.haneefa@agiratech.com)

Thanks.

@Developer-Platform any help here?

1 Like

Hi @Mohamed_Haneefa,

Looks like the file upload via multipart form upload would be taking only the first chuck of the stream. Did you try sending it by concatenating the stream pipe? Maybe you would have to use a npm package - concat-stream.

Let me know if this helps.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.