用id(使用onedrive api)替换onedrive中的现有文件内容是否替换为空大小文件? &g



遵循此API文档https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_put_content?view=odsp-graph-online

这里是代码,已经尝试了所有可能的东西在主体中传递,这里,req.file.buffer是imageBuffer

const { Readable } = require("stream");

const { data } = await axios({
method: "put",
url: `https://graph.microsoft.com/v1.0/me/drive/items/${fileId}/content`,
headers: {
Authorization: "bearer " + req.user.auth.accessToken,
"Content-Type": "application/pdf",
},
responseType: "json",
body: Readable.from(req.file.buffer.toString()),
});

body期望Buffer,Blob,File,FormDataString。我不确定你的imageBuffer。如果是这样,您应该执行

body: Buffer.from(req.file.buffer.uint8.content)

此外,在您的Authorization标题中,它应该是Bearer,而不是bearer,尽管我不认为这是问题的主要原因。

最新更新