We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
予想: requestがmultipart/form-dataに対応してない?
multipart/form-data
自分のやり方が間違っている可能性がある?のでミニマムで再現しようとしたコードサンプルもつけておきます
misskey-jsを用いてドライブにファイルアップロードができる
misskey-jsを用いてドライブにファイルアップロードができない
最小で再現しようとしたCode Sample (nodejs@20)
Sample ```ts import { readFileSync } from 'fs'; import * as Misskey from 'misskey-js' export function fileToBlob(filePath: string): Blob { // ファイルをバイナリデータとして読み込む const fileBuffer = readFileSync(filePath); // バイナリデータをUint8Arrayに変換 const uint8Array = new Uint8Array(fileBuffer); // Blobオブジェクトを作成 const blob = new Blob([uint8Array]); return blob; } export async function blobTobinaryText(blob: Blob): Promise<string> { return new Promise((resolve, reject) => { try { // ファイルをバイナリデータとして読み込む const fileBuffer = readFileSync(filePath); // バッファをバイナリ文字列に変換 const binaryString = fileBuffer.toString('binary'); resolve(binaryString); } catch (error) { reject(error); } }); } export async function fileToBinaryText(filePath: string): Promise<string> { const blob = fileToBlob(filePath); return blobTobinaryText(blob); } const filePath = '/home/taichan/heat_storoke_alert_bot/captures/today.png'; const binary = await fileToBinaryText(filePath); const apiClient = new Misskey.api.APIClient({ origin: 'https://mi.taichan.site', credential: 'It6ipr8s17tFvq6k791YOgyw0kioTB7u' }) // uploaded1 will be TypeError // const uploaded1 = apiClient.request('drive/files/create', { file: fileToBlob(filePath) } as Misskey.Endpoints['drive/files/create']['req']) //TypeError const uploaded2 = apiClient.request('drive/files/create', { file: binary } as Misskey.Endpoints['drive/files/create']['req']) //console.log(uploaded1) console.log(uploaded2) // Result: // SyntaxError: Unexpected end of JSON input // at JSON.parse (<anonymous>)
* Model and OS of the device(s): * Browser: * Server URL: * Misskey:
* Installation Method or Hosting Service: * Misskey: * Node: * PostgreSQL: * Redis: * OS and Architecture:
The text was updated successfully, but these errors were encountered:
正解
Sorry, something went wrong.
一応検証まで書いた https://github.com/tai-cha/misskey-js-drive-upload-bug-verification
Successfully merging a pull request may close this issue.
💡 Summary
予想: requestが
multipart/form-data
に対応してない?自分のやり方が間違っている可能性がある?のでミニマムで再現しようとしたコードサンプルもつけておきます
🥰 Expected Behavior
misskey-jsを用いてドライブにファイルアップロードができる
🤬 Actual Behavior
misskey-jsを用いてドライブにファイルアップロードができない
📝 Steps to Reproduce
最小で再現しようとしたCode Sample (nodejs@20)
code environment
💻 Frontend Environment
🛰 Backend Environment (for server admin)
Do you want to address this bug yourself?
The text was updated successfully, but these errors were encountered: