Commit d5b1d4a8 authored by nanahira's avatar nanahira

fix downloading pic

parent 9be2f2b4
......@@ -60,7 +60,7 @@ export class TestMultiPicSourcePlugin extends MultiInstancePlugin(
export default class ExtrasInDev {
constructor(ctx: Context) {
ctx.plugin(TestPlainPicSourcePlugin, {
ctx.plugin(TestPicSourcePlugin, {
// name: 'zh-CN',
isDefault: true,
// endpoint: 'https://cdn02.moecube.com:444',
......
import { Context } from 'koishi';
import TargetPlugin from '../src';
import ConsolePlugin from '@koishijs/plugin-console';
import SandboxPlugin from '@koishijs/plugin-sandbox';
import * as SandboxPlugin from '@koishijs/plugin-sandbox';
import DatabasePlugin from '@koishijs/plugin-database-memory';
import ExtrasInDev from './extras';
......
{
"name": "koishi-plugin-pics",
"version": "10.3.0",
"version": "10.3.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "koishi-plugin-pics",
"version": "10.3.0",
"version": "10.3.1",
"license": "MIT",
"dependencies": {
"koishi-thirdeye": "^11.1.11",
"lodash": "^4.17.21"
},
"devDependencies": {
"@koishijs/plugin-console": "^4.5.4",
"@koishijs/plugin-console": "^4.6.9",
"@koishijs/plugin-database-memory": "^1.5.0",
"@koishijs/plugin-sandbox": "^2.2.9",
"@koishijs/plugin-sandbox": "^2.3.3",
"@types/jest": "^29.2.0",
"@types/lodash": "^4.14.176",
"@types/node": "^16.11.4",
......@@ -1399,9 +1399,9 @@
}
},
"node_modules/@koishijs/plugin-console": {
"version": "4.5.4",
"resolved": "https://registry.npmjs.org/@koishijs/plugin-console/-/plugin-console-4.5.4.tgz",
"integrity": "sha512-s6qsQAd5Qch4m7G0FaXZMPsgVOOnjchpCs55ElnU28FB/j7gW9OfhjpBihQ6EkK3Ll3R0IFerXnEC6mC+c5N5w==",
"version": "4.6.9",
"resolved": "https://registry.npmjs.org/@koishijs/plugin-console/-/plugin-console-4.6.9.tgz",
"integrity": "sha512-xBvXaJ2TxtclE8UxmDnBfX4kc2pqgnmiJ4+zxGztnIRQi5FF/NCqWdiwyWBcqV2SmZEqs/CBdzyhoSXOWXp5sw==",
"dev": true,
"dependencies": {
"open": "^8.4.0",
......@@ -1409,7 +1409,7 @@
"ws": "^8.8.1"
},
"peerDependencies": {
"koishi": "^4.9.0"
"koishi": "^4.9.6"
}
},
"node_modules/@koishijs/plugin-database-memory": {
......@@ -1425,13 +1425,13 @@
}
},
"node_modules/@koishijs/plugin-sandbox": {
"version": "2.2.9",
"resolved": "https://registry.npmjs.org/@koishijs/plugin-sandbox/-/plugin-sandbox-2.2.9.tgz",
"integrity": "sha512-UOU3ZlM3Z5uW/Kd5rAsoxlACvvh8JqhPWl+nzCzu1FFptohU2vhaeHX9Hvp9d7iHppJ2JwHjSGK6Jw55yqQWjA==",
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/@koishijs/plugin-sandbox/-/plugin-sandbox-2.3.3.tgz",
"integrity": "sha512-I4b3BQcsjbiSIo4hzCCEN3zHS47E4ocqQ5NXt1nRmA9djKoEt76liK7Gs0klTjfJYLhoswZjfmYpoKjF1QLY8A==",
"dev": true,
"peerDependencies": {
"@koishijs/plugin-console": "^4.4.12",
"koishi": "^4.8.7"
"@koishijs/plugin-console": "^4.6.9",
"koishi": "^4.9.7"
}
},
"node_modules/@koishijs/utils": {
......@@ -9413,9 +9413,9 @@
}
},
"@koishijs/plugin-console": {
"version": "4.5.4",
"resolved": "https://registry.npmjs.org/@koishijs/plugin-console/-/plugin-console-4.5.4.tgz",
"integrity": "sha512-s6qsQAd5Qch4m7G0FaXZMPsgVOOnjchpCs55ElnU28FB/j7gW9OfhjpBihQ6EkK3Ll3R0IFerXnEC6mC+c5N5w==",
"version": "4.6.9",
"resolved": "https://registry.npmjs.org/@koishijs/plugin-console/-/plugin-console-4.6.9.tgz",
"integrity": "sha512-xBvXaJ2TxtclE8UxmDnBfX4kc2pqgnmiJ4+zxGztnIRQi5FF/NCqWdiwyWBcqV2SmZEqs/CBdzyhoSXOWXp5sw==",
"dev": true,
"requires": {
"open": "^8.4.0",
......@@ -9433,9 +9433,9 @@
}
},
"@koishijs/plugin-sandbox": {
"version": "2.2.9",
"resolved": "https://registry.npmjs.org/@koishijs/plugin-sandbox/-/plugin-sandbox-2.2.9.tgz",
"integrity": "sha512-UOU3ZlM3Z5uW/Kd5rAsoxlACvvh8JqhPWl+nzCzu1FFptohU2vhaeHX9Hvp9d7iHppJ2JwHjSGK6Jw55yqQWjA==",
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/@koishijs/plugin-sandbox/-/plugin-sandbox-2.3.3.tgz",
"integrity": "sha512-I4b3BQcsjbiSIo4hzCCEN3zHS47E4ocqQ5NXt1nRmA9djKoEt76liK7Gs0klTjfJYLhoswZjfmYpoKjF1QLY8A==",
"dev": true,
"requires": {}
},
......
......@@ -182,11 +182,17 @@ export default class PicsContainer
);
}
async urlToBuffer(url: string, extraConfig: AxiosRequestConfig = {}): Promise<Buffer> {
async urlToBuffer(
url: string,
extraConfig: AxiosRequestConfig = {},
): Promise<Buffer> {
if (url.startsWith('base64://')) {
return Buffer.from(url.slice(9), 'base64');
}
const { data } = await this._http.file(url);
const data = await this._http.get<Buffer>(url, {
responseType: 'arraybuffer',
...extraConfig,
});
return data as Buffer;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment