mirror of
https://github.com/misskey-dev/media-proxy.git
synced 2025-08-08 09:13:51 +09:00
Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
6bf5fbd794 | |||
72431d805e | |||
c3738a339a | |||
99f0160e17 | |||
bd6f63b60e | |||
384c51569f | |||
57aa87f370 |
@ -4,8 +4,6 @@
|
|||||||
|
|
||||||
Misskeyの/proxyが単体で動作します(Misskeyのコードがほぼそのまま移植されています)。
|
Misskeyの/proxyが単体で動作します(Misskeyのコードがほぼそのまま移植されています)。
|
||||||
|
|
||||||
/proxyは画像ではないと403を返しますが、Media Proxyではそのまま内容を送信します。
|
|
||||||
|
|
||||||
**Fastifyプラグインとして動作する気がします。**
|
**Fastifyプラグインとして動作する気がします。**
|
||||||
`pnpm start`は[fastify-cli](https://github.com/fastify/fastify-cli)が動作します。
|
`pnpm start`は[fastify-cli](https://github.com/fastify/fastify-cli)が動作します。
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ https://www.google.com/images/errors/robot.png をプロキシする場合:
|
|||||||
#### static
|
#### static
|
||||||
存在すると、アニメーション画像では最初のフレームのみの静止画のwebpが応答される。
|
存在すると、アニメーション画像では最初のフレームのみの静止画のwebpが応答される。
|
||||||
|
|
||||||
emojiまたはavatarとstaticが同時に指定された場合は、それぞれに応じた高さが、指定されていない場合は幅498px・高さ280pxに収まるサイズ以下に縮小される。
|
emojiまたはavatarとstaticが同時に指定された場合は、それぞれに応じた高さが、指定されていない場合は幅498px・高さ422pxに収まるサイズ以下に縮小される。
|
||||||
|
|
||||||
#### preview
|
#### preview
|
||||||
存在すると、幅200px・高さ200pxに収まるサイズ以下のwebpが応答される。
|
存在すると、幅200px・高さ200pxに収まるサイズ以下のwebpが応答される。
|
||||||
|
@ -61,9 +61,14 @@ export async function downloadUrl(url, path, settings = defaultDownloadConfig) {
|
|||||||
}
|
}
|
||||||
const contentDisposition = res.headers['content-disposition'];
|
const contentDisposition = res.headers['content-disposition'];
|
||||||
if (contentDisposition != null) {
|
if (contentDisposition != null) {
|
||||||
const parsed = parse(contentDisposition);
|
try {
|
||||||
if (parsed.parameters.filename) {
|
const parsed = parse(contentDisposition);
|
||||||
filename = parsed.parameters.filename;
|
if (parsed.parameters.filename) {
|
||||||
|
filename = parsed.parameters.filename;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
console.log(`Failed to parse content-disposition: ${contentDisposition}\n${e}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).on('downloadProgress', (progress) => {
|
}).on('downloadProgress', (progress) => {
|
||||||
|
@ -122,7 +122,7 @@ async function proxyHandler(request, reply) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ('static' in request.query) {
|
else if ('static' in request.query) {
|
||||||
image = convertSharpToWebpStream(await sharpBmp(file.path, file.mime), 498, 280);
|
image = convertSharpToWebpStream(await sharpBmp(file.path, file.mime), 498, 422);
|
||||||
}
|
}
|
||||||
else if ('preview' in request.query) {
|
else if ('preview' in request.query) {
|
||||||
image = convertSharpToWebpStream(await sharpBmp(file.path, file.mime), 200, 200);
|
image = convertSharpToWebpStream(await sharpBmp(file.path, file.mime), 200, 200);
|
||||||
@ -130,7 +130,8 @@ async function proxyHandler(request, reply) {
|
|||||||
else if ('badge' in request.query) {
|
else if ('badge' in request.query) {
|
||||||
const mask = (await sharpBmp(file.path, file.mime))
|
const mask = (await sharpBmp(file.path, file.mime))
|
||||||
.resize(96, 96, {
|
.resize(96, 96, {
|
||||||
fit: 'inside',
|
fit: 'contain',
|
||||||
|
position: 'centre',
|
||||||
withoutEnlargement: false,
|
withoutEnlargement: false,
|
||||||
})
|
})
|
||||||
.greyscale()
|
.greyscale()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "misskey-media-proxy",
|
"name": "misskey-media-proxy",
|
||||||
"version": "0.0.18",
|
"version": "0.0.21",
|
||||||
"description": "The Media Proxy for Misskey",
|
"description": "The Media Proxy for Misskey",
|
||||||
"main": "built/index.js",
|
"main": "built/index.js",
|
||||||
"packageManager": "pnpm@7.28.0",
|
"packageManager": "pnpm@7.28.0",
|
||||||
|
@ -82,9 +82,13 @@ export async function downloadUrl(url: string, path: string, settings:DownloadCo
|
|||||||
|
|
||||||
const contentDisposition = res.headers['content-disposition'];
|
const contentDisposition = res.headers['content-disposition'];
|
||||||
if (contentDisposition != null) {
|
if (contentDisposition != null) {
|
||||||
const parsed = parse(contentDisposition);
|
try {
|
||||||
if (parsed.parameters.filename) {
|
const parsed = parse(contentDisposition);
|
||||||
filename = parsed.parameters.filename;
|
if (parsed.parameters.filename) {
|
||||||
|
filename = parsed.parameters.filename;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log(`Failed to parse content-disposition: ${contentDisposition}\n${e}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).on('downloadProgress', (progress: Got.Progress) => {
|
}).on('downloadProgress', (progress: Got.Progress) => {
|
||||||
|
@ -168,13 +168,14 @@ async function proxyHandler(request: FastifyRequest<{ Params: { url: string; };
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
} else if ('static' in request.query) {
|
} else if ('static' in request.query) {
|
||||||
image = convertSharpToWebpStream(await sharpBmp(file.path, file.mime), 498, 280);
|
image = convertSharpToWebpStream(await sharpBmp(file.path, file.mime), 498, 422);
|
||||||
} else if ('preview' in request.query) {
|
} else if ('preview' in request.query) {
|
||||||
image = convertSharpToWebpStream(await sharpBmp(file.path, file.mime), 200, 200);
|
image = convertSharpToWebpStream(await sharpBmp(file.path, file.mime), 200, 200);
|
||||||
} else if ('badge' in request.query) {
|
} else if ('badge' in request.query) {
|
||||||
const mask = (await sharpBmp(file.path, file.mime))
|
const mask = (await sharpBmp(file.path, file.mime))
|
||||||
.resize(96, 96, {
|
.resize(96, 96, {
|
||||||
fit: 'inside',
|
fit: 'contain',
|
||||||
|
position: 'centre',
|
||||||
withoutEnlargement: false,
|
withoutEnlargement: false,
|
||||||
})
|
})
|
||||||
.greyscale()
|
.greyscale()
|
||||||
|
Reference in New Issue
Block a user