ali-sdk / ali-oss

Aliyun OSS(Object Storage Service) JavaScript SDK for the Browser and Node.js
https://www.alibabacloud.com/help/doc-detail/52834.htm
MIT License
1.96k stars 576 forks source link

Can't upload file in AppSmith #1332

Open tengfei86 opened 2 months ago

tengfei86 commented 2 months ago

        try {
            // 获取上传的文件
            const file = FilePicker.files[0];
            const options = {
                meta: { temp: "demo" },
                mime: "json",
                headers: { "Content-Type": "text/plain" },
            };
            // const blob = new Blob([bytes],{type: fileType});
            var data = new Blob(['This is the sample data']);
            // 将文件上传到阿里云OSS
            const result = await client.put("debug.txt", data,options);
            console.log("=========");
            console.log(result);
            // 显示上传成功的消息
            showAlert('上传成功', 'success');

            // 获取上传后的文件URL
            const uploadedFileUrl = result.url;
            console.log("Uploaded File URL:", uploadedFileUrl);

            // 将上传的文件URL保存到变量
            myvar1 = uploadedFileUrl;

            // 返回文件URL,或者在需要的地方使用这个变量
            return myvar1;

        } catch (e) {
            // 显示上传失败的消息
            console.log("caceh" + e);
            showAlert('上传失败: ' + e.message, 'error');
        }

this log file is as below ,you can refer 47.94.208.160-1724898269844.log

tengfei86 commented 2 months ago

Any update ?

YunZZY commented 2 months ago

The provided code snippet does not reveal any apparent issues. However, based on the log information, the following problems may exist:

  1. The usage of the "Expect" request header
  2. The usage of Webworker, but this SDK does not support Webworker at present

If it is not due to the above reasons, please provide a minimal reproducible repository and steps to reproduce it so that we can check it out.