Error with Uploadthing file renaming

I tried using both Rename types: Rename || Rename[] Whenever I try to send this request:
if (data.name !== originalDocument.name) {
await utapi.renameFiles({
key: originalDocument.fileKey,
newName: data.name,
});
}
if (data.name !== originalDocument.name) {
await utapi.renameFiles({
key: originalDocument.fileKey,
newName: data.name,
});
}
Example of originalDocument.fileKey: <GUID>.pdf Example of file name: file name with space and ext.pdf Error:
[
⨯ UPLOADTHING 4:02:27 PM "Request failed:",
⨯ UPLOADTHING 4:02:27 PM {
⨯ UPLOADTHING 4:02:27 PM "error": "Request to https://uploadthing.com/api/renameFiles failed with status 400",
⨯ UPLOADTHING 4:02:27 PM "data": {
⨯ UPLOADTHING 4:02:27 PM "error": "Invalid request input",
⨯ UPLOADTHING 4:02:27 PM "data": [
⨯ UPLOADTHING 4:02:27 PM {
⨯ UPLOADTHING 4:02:27 PM "code": "custom",
⨯ UPLOADTHING 4:02:27 PM "message": "Must provide either fileKey or customId, but not both.",
⨯ UPLOADTHING 4:02:27 PM "path": [
⨯ UPLOADTHING 4:02:27 PM "updates",
⨯ UPLOADTHING 4:02:27 PM 0
⨯ UPLOADTHING 4:02:27 PM ]
⨯ UPLOADTHING 4:02:27 PM }
⨯ UPLOADTHING 4:02:27 PM ]
⨯ UPLOADTHING 4:02:27 PM },
⨯ UPLOADTHING 4:02:27 PM "input": "https://uploadthing.com/api/renameFiles",
⨯ UPLOADTHING 4:02:27 PM "_tag": "FetchError"
⨯ UPLOADTHING 4:02:27 PM }
⨯ UPLOADTHING 4:02:27 PM ]
[
⨯ UPLOADTHING 4:02:27 PM "Request failed:",
⨯ UPLOADTHING 4:02:27 PM {
⨯ UPLOADTHING 4:02:27 PM "error": "Request to https://uploadthing.com/api/renameFiles failed with status 400",
⨯ UPLOADTHING 4:02:27 PM "data": {
⨯ UPLOADTHING 4:02:27 PM "error": "Invalid request input",
⨯ UPLOADTHING 4:02:27 PM "data": [
⨯ UPLOADTHING 4:02:27 PM {
⨯ UPLOADTHING 4:02:27 PM "code": "custom",
⨯ UPLOADTHING 4:02:27 PM "message": "Must provide either fileKey or customId, but not both.",
⨯ UPLOADTHING 4:02:27 PM "path": [
⨯ UPLOADTHING 4:02:27 PM "updates",
⨯ UPLOADTHING 4:02:27 PM 0
⨯ UPLOADTHING 4:02:27 PM ]
⨯ UPLOADTHING 4:02:27 PM }
⨯ UPLOADTHING 4:02:27 PM ]
⨯ UPLOADTHING 4:02:27 PM },
⨯ UPLOADTHING 4:02:27 PM "input": "https://uploadthing.com/api/renameFiles",
⨯ UPLOADTHING 4:02:27 PM "_tag": "FetchError"
⨯ UPLOADTHING 4:02:27 PM }
⨯ UPLOADTHING 4:02:27 PM ]
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server