TypeError [ERR_INVALID_ARG_TYPE]: The "paths[0]" argument must be of type string. Received an instance of Object
维护者通常 2 天内回复
@sofisl 已经在做这个了。
开始于 2024年2月26日。
评估
这个 Issue 还没有评估数据。
描述
hi i got this error
"TypeError [ERR_INVALID_ARG_TYPE]: The "paths[0]" argument must be of type string. Received an instance of Object"
every time i try to upload a file to my drive account and here is the code
"use server";
import { google } from "googleapis";
import * as fs from "fs";
import { join } from "path";
export async function addFile(e: FormData) {
const file: File | null = e.get("file") as unknown as File;
const bytes = await file?.arrayBuffer();
const buffer = Buffer.from(bytes);
const path = join("/", "/tmp", file.name.trim());
fs.writeFileSync(path, buffer);
const keyFile = await JSON.parse(
fs.readFileSync(process.cwd() + `/src/app/key.json`, "utf-8")
);
const auth = new google.auth.GoogleAuth({
keyFile,
scopes: ["https://www.googleapis.com/auth/drive"],
});
const drive = google.drive({
version: "v3",
auth,
});
const response = () => {
return new Promise((resolve, reject) => {
drive.files.create(
{
requestBody: {
name: file.name,
parents: ["1TebOIirZf_P9xb2Vc2fAVhdMrTU_rN-U"],
},
media: {
body: fs.createReadStream(path),
mimeType: file.type.toString(),
},
fields: "id",
},
function (err, file) {
if (err) {
reject(err);
}
resolve(file);
}
);
});
};
await response().catch((err) => console.log(err));
}
so could any one help with that or have a tip for solve this problem
i use next.js 14.1.0 as a javascript frame work node with version 20.9.0
- 主要语言
- TypeScript
- 星标
- 12.3k
- 派生
- 2k
- 平均合并
- 3 天 10 小时
- 30 天内合并 PR
- 9
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
googleapis/google-api-nodejs-client 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 86/100
googleapis/google-api-nodejs-client#4064 ·
维护者通常 2 天内回复
-
难度 4/5 1-2 天 新手友好度 5/100
googleapis/google-api-nodejs-client#4067 ·
维护者通常 2 天内回复
-
难度 5/5 一周以上 新手友好度 1/100
googleapis/google-api-nodejs-client#4063 ·
维护者通常 2 天内回复
-
eMudhra/emSign CA compromise (October 2026): what Cloud SDK Node.js Libraries developers need to do未关闭
难度 1/5 1 小时以内 新手友好度 10/100
googleapis/google-api-nodejs-client#4062 ·
维护者通常 2 天内回复
-
难度 5/5 一周以上 新手友好度 10/100
googleapis/google-api-nodejs-client#4061 ·
维护者通常 2 天内回复
查看 googleapis/google-api-nodejs-client 的全部 Issue
相似的 Issue
-
bug UI
难度 2/5 1-3 小时 新手友好度 70/100
wardian-app/Wardian#1746 ·
维护者通常 1 天内回复
-
area: interop area: sip-core v3
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P2
难度 2/5 1-3 小时 新手友好度 72/100
openclaw/openclaw#198551 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复