Javascript 我可以使用签名的url上传到共享空间吗?

Javascript 我可以使用签名的url上传到共享空间吗?,javascript,node.js,reactjs,react-redux,digital-ocean,Javascript,Node.js,Reactjs,React Redux,Digital Ocean,我目前正在开发一个React网络应用程序,允许用户上传图像。我有它与AWS S3的工作,但想有一切做简单的缘故 流程如下所示: 将图像信息发送到服务器并接收签名的url 将图像发布到已签名的url const xhr = new XMLHttpRequest(); xhr.withCredentials = true; xhr.open('PUT', payload.signedUrl); xhr.setRequestHeader('Host', `${DO_SPACE}.${DO_REGION

我目前正在开发一个React网络应用程序,允许用户上传图像。我有它与AWS S3的工作,但想有一切做简单的缘故

流程如下所示:

将图像信息发送到服务器并接收签名的url 将图像发布到已签名的url

const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.open('PUT', payload.signedUrl);
xhr.setRequestHeader('Host', `${DO_SPACE}.${DO_REGION}.digitaloceanspaces.com');
xhr.setRequestHeader('x-amz-acl', 'public-read');
xhr.setRequestHeader('Content-Type', payload.file.type);
xhr.setRequestHeader('Content-Length', payload.file.size);
xhr.send(payload.file);
当我尝试使用空格时,我经常会遇到“SignatureDesNotMatch”错误

请帮帮我,我快疯了

生成已签名url的我的节点服务器:

spacesEndpoint = new aws.Endpoint(`${DO_REGION}.digitaloceanspaces.com`),
s3 = new aws.S3({
    endpoint: spacesEndpoint,
    accessKeyId: DO_ACCESS_KEY_ID,
    secretAccessKey: DO_SECRET_ACCESS_KEY,
    region: DO_REGION,
    signatureVersion: 'v4',
});

const s3Params = {
    Bucket: DO_SPACE,
    Expires: 60,
    Key: filePath,
    ContentType: fileType, // "image/jpeg"
    ACL: 'public-read',
};

const promise = new Promise((resolve, reject) => {
    s3.getSignedUrl('putObject', s3Params, (err, url) => {
        if (err) {
            reject(err);
        }
        resolve(url);
    });
});
检索签名url后我的客户端js发布

const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.open('PUT', payload.signedUrl);
xhr.setRequestHeader('Host', `${DO_SPACE}.${DO_REGION}.digitaloceanspaces.com');
xhr.setRequestHeader('x-amz-acl', 'public-read');
xhr.setRequestHeader('Content-Type', payload.file.type);
xhr.setRequestHeader('Content-Length', payload.file.size);
xhr.send(payload.file);