【问题标题】:How to create CSV file in netsuite with base64 content?如何在 netsuite 中创建包含 base64 内容的 CSV 文件?
【发布时间】:2023-01-27 18:51:23
【问题描述】:

我正在从网上下载一个文件,我需要将他保存在文件柜中,但是当我保存它时它是一个空文件(0kb)。

 let response = https.get({
                url: url
            });

 log.debug('response', JSON.stringify(response.body)) //getting the file content
 let fileContent = response.body;
 let decodedStr = fileToBase64(fileContent); // get base64 content

let createFile = file.create({
                name: "test.csv",
                fileType: file.Type.CSV,
                content: decodedStr,
                folder: 1000
            });

            createFile.save();




//get base 64 
   function fileToBase64(stringInput) {
            return encode.convert({
                string: stringInput,
                inputEncoding: encode.Encoding.UTF_8,
                outputEncoding: encode.Encoding.BASE_64
            });
        }

仍然得到一个空的 csv 文件。

【问题讨论】:

    标签: javascript netsuite suitescript suitescript2.0


    【解决方案1】:

    我怀疑如果它 base64Encoded 文件类型不应该是 CSV 而是 file.Type.PLAINTEXT

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-25
      • 2018-12-21
      • 2023-01-14
      • 2014-01-13
      • 1970-01-01
      • 2020-09-17
      • 1970-01-01
      • 2016-07-25
      相关资源
      最近更新 更多