aaa
This commit is contained in:
parent
6ac1e417dd
commit
f5537af8a1
|
@ -171,6 +171,7 @@ errorRouter.all("(.*)", async (ctx) => {
|
||||||
|
|
||||||
// Register router
|
// Register router
|
||||||
app.use(mastoRouter.routes());
|
app.use(mastoRouter.routes());
|
||||||
|
app.use(mastoRouter.allowedMethods());
|
||||||
app.use(router.routes());
|
app.use(router.routes());
|
||||||
app.use(errorRouter.routes());
|
app.use(errorRouter.routes());
|
||||||
|
|
||||||
|
|
|
@ -289,14 +289,16 @@ export function apiStatusMastodon(router: Router): void {
|
||||||
const accessTokens = ctx.headers.authorization;
|
const accessTokens = ctx.headers.authorization;
|
||||||
const client = getClient(BASE_URL, accessTokens);
|
const client = getClient(BASE_URL, accessTokens);
|
||||||
try {
|
try {
|
||||||
const multipartData = await ctx.file;
|
let multipartData = await ctx.request.files;
|
||||||
if (!multipartData) {
|
if (!multipartData) {
|
||||||
ctx.body = { error: "No image" };
|
ctx.body = { error: "No image" };
|
||||||
|
ctx.status = 401;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const [path] = await createTemp();
|
if ((multipartData as any).file) {
|
||||||
await pump(multipartData.buffer, fs.createWriteStream(path));
|
multipartData = (multipartData as any).file;
|
||||||
const image = fs.readFileSync(path);
|
}
|
||||||
|
const image = fs.readFileSync((multipartData as any).path);
|
||||||
const data = await client.uploadMedia(image);
|
const data = await client.uploadMedia(image);
|
||||||
ctx.body = data.data;
|
ctx.body = data.data;
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
|
@ -313,6 +315,7 @@ export function apiStatusMastodon(router: Router): void {
|
||||||
const multipartData = await ctx.file;
|
const multipartData = await ctx.file;
|
||||||
if (!multipartData) {
|
if (!multipartData) {
|
||||||
ctx.body = { error: "No image" };
|
ctx.body = { error: "No image" };
|
||||||
|
ctx.status = 401;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const [path] = await createTemp();
|
const [path] = await createTemp();
|
||||||
|
|
Loading…
Reference in New Issue