mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-23 06:33:08 +02:00
upd: use uploadMedia function
This commit is contained in:
parent
6a52509821
commit
7c64dce1ad
1 changed files with 2 additions and 20 deletions
|
@ -234,31 +234,13 @@ export default class Misskey implements MegalodonInterface {
|
|||
})
|
||||
}
|
||||
if (options.avatar) {
|
||||
const formData = new FormData()
|
||||
formData.append('file', fs.createReadStream(file.path), {
|
||||
contentType: file.mimetype,
|
||||
});
|
||||
if (file.originalname != null && file.originalname !== "file") formData.append("name", file.originalname);
|
||||
let headers: { [key: string]: string } = {}
|
||||
if (typeof formData.getHeaders === 'function') {
|
||||
headers = formData.getHeaders()
|
||||
}
|
||||
const media = await this.client.post<MisskeyAPI.Entity.File>('/api/drive/files/create', formData, headers);
|
||||
const media = await this.uploadMedia(file);
|
||||
params = Object.assign(params, {
|
||||
avatarId: media.data.id
|
||||
})
|
||||
}
|
||||
if (options.header) {
|
||||
const formData = new FormData()
|
||||
formData.append('file', fs.createReadStream(file.path), {
|
||||
contentType: file.mimetype,
|
||||
});
|
||||
if (file.originalname != null && file.originalname !== "file") formData.append("name", file.originalname);
|
||||
let headers: { [key: string]: string } = {}
|
||||
if (typeof formData.getHeaders === 'function') {
|
||||
headers = formData.getHeaders()
|
||||
}
|
||||
const media = await this.client.post<MisskeyAPI.Entity.File>('/api/drive/files/create', formData, headers);
|
||||
const media = await this.uploadMedia(file);
|
||||
params = Object.assign(params, {
|
||||
headerId: media.data.id
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue