Fix media upload

This commit is contained in:
Laura Hausmann 2023-07-05 20:05:49 +02:00
parent 6ca8fc7231
commit f8c328ff55
Signed by: zotan
GPG key ID: D044E84C5BE01605

View file

@ -9,6 +9,7 @@ import Response from './response'
import Entity from './entity'
import { MegalodonInterface, WebSocketInterface, NoImplementedError, ArgumentError, UnexpectedError } from './megalodon'
import MegalodonEntity from "@/entity";
import fs from "node:fs";
type AccountCache = {
locks: AsyncLock,
@ -1579,7 +1580,7 @@ export default class Misskey implements MegalodonInterface {
*/
public async uploadMedia(file: any, _options?: { description?: string; focus?: string }): Promise<Response<Entity.Attachment>> {
const formData = new FormData()
formData.append('file', file.buffer, {
formData.append('file', fs.createReadStream(file.path), {
contentType: file.mimetype,
filename: file.originalname,
})