Commit d5b1d4a8 authored by nanahira's avatar nanahira

fix downloading pic

parent 9be2f2b4
...@@ -60,7 +60,7 @@ export class TestMultiPicSourcePlugin extends MultiInstancePlugin( ...@@ -60,7 +60,7 @@ export class TestMultiPicSourcePlugin extends MultiInstancePlugin(
export default class ExtrasInDev { export default class ExtrasInDev {
constructor(ctx: Context) { constructor(ctx: Context) {
ctx.plugin(TestPlainPicSourcePlugin, { ctx.plugin(TestPicSourcePlugin, {
// name: 'zh-CN', // name: 'zh-CN',
isDefault: true, isDefault: true,
// endpoint: 'https://cdn02.moecube.com:444', // endpoint: 'https://cdn02.moecube.com:444',
......
import { Context } from 'koishi'; import { Context } from 'koishi';
import TargetPlugin from '../src'; import TargetPlugin from '../src';
import ConsolePlugin from '@koishijs/plugin-console'; 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 DatabasePlugin from '@koishijs/plugin-database-memory';
import ExtrasInDev from './extras'; import ExtrasInDev from './extras';
......
{ {
"name": "koishi-plugin-pics", "name": "koishi-plugin-pics",
"version": "10.3.0", "version": "10.3.1",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "koishi-plugin-pics", "name": "koishi-plugin-pics",
"version": "10.3.0", "version": "10.3.1",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"koishi-thirdeye": "^11.1.11", "koishi-thirdeye": "^11.1.11",
"lodash": "^4.17.21" "lodash": "^4.17.21"
}, },
"devDependencies": { "devDependencies": {
"@koishijs/plugin-console": "^4.5.4", "@koishijs/plugin-console": "^4.6.9",
"@koishijs/plugin-database-memory": "^1.5.0", "@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/jest": "^29.2.0",
"@types/lodash": "^4.14.176", "@types/lodash": "^4.14.176",
"@types/node": "^16.11.4", "@types/node": "^16.11.4",
...@@ -1399,9 +1399,9 @@ ...@@ -1399,9 +1399,9 @@
} }
}, },
"node_modules/@koishijs/plugin-console": { "node_modules/@koishijs/plugin-console": {
"version": "4.5.4", "version": "4.6.9",
"resolved": "https://registry.npmjs.org/@koishijs/plugin-console/-/plugin-console-4.5.4.tgz", "resolved": "https://registry.npmjs.org/@koishijs/plugin-console/-/plugin-console-4.6.9.tgz",
"integrity": "sha512-s6qsQAd5Qch4m7G0FaXZMPsgVOOnjchpCs55ElnU28FB/j7gW9OfhjpBihQ6EkK3Ll3R0IFerXnEC6mC+c5N5w==", "integrity": "sha512-xBvXaJ2TxtclE8UxmDnBfX4kc2pqgnmiJ4+zxGztnIRQi5FF/NCqWdiwyWBcqV2SmZEqs/CBdzyhoSXOWXp5sw==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"open": "^8.4.0", "open": "^8.4.0",
...@@ -1409,7 +1409,7 @@ ...@@ -1409,7 +1409,7 @@
"ws": "^8.8.1" "ws": "^8.8.1"
}, },
"peerDependencies": { "peerDependencies": {
"koishi": "^4.9.0" "koishi": "^4.9.6"
} }
}, },
"node_modules/@koishijs/plugin-database-memory": { "node_modules/@koishijs/plugin-database-memory": {
...@@ -1425,13 +1425,13 @@ ...@@ -1425,13 +1425,13 @@
} }
}, },
"node_modules/@koishijs/plugin-sandbox": { "node_modules/@koishijs/plugin-sandbox": {
"version": "2.2.9", "version": "2.3.3",
"resolved": "https://registry.npmjs.org/@koishijs/plugin-sandbox/-/plugin-sandbox-2.2.9.tgz", "resolved": "https://registry.npmjs.org/@koishijs/plugin-sandbox/-/plugin-sandbox-2.3.3.tgz",
"integrity": "sha512-UOU3ZlM3Z5uW/Kd5rAsoxlACvvh8JqhPWl+nzCzu1FFptohU2vhaeHX9Hvp9d7iHppJ2JwHjSGK6Jw55yqQWjA==", "integrity": "sha512-I4b3BQcsjbiSIo4hzCCEN3zHS47E4ocqQ5NXt1nRmA9djKoEt76liK7Gs0klTjfJYLhoswZjfmYpoKjF1QLY8A==",
"dev": true, "dev": true,
"peerDependencies": { "peerDependencies": {
"@koishijs/plugin-console": "^4.4.12", "@koishijs/plugin-console": "^4.6.9",
"koishi": "^4.8.7" "koishi": "^4.9.7"
} }
}, },
"node_modules/@koishijs/utils": { "node_modules/@koishijs/utils": {
...@@ -9413,9 +9413,9 @@ ...@@ -9413,9 +9413,9 @@
} }
}, },
"@koishijs/plugin-console": { "@koishijs/plugin-console": {
"version": "4.5.4", "version": "4.6.9",
"resolved": "https://registry.npmjs.org/@koishijs/plugin-console/-/plugin-console-4.5.4.tgz", "resolved": "https://registry.npmjs.org/@koishijs/plugin-console/-/plugin-console-4.6.9.tgz",
"integrity": "sha512-s6qsQAd5Qch4m7G0FaXZMPsgVOOnjchpCs55ElnU28FB/j7gW9OfhjpBihQ6EkK3Ll3R0IFerXnEC6mC+c5N5w==", "integrity": "sha512-xBvXaJ2TxtclE8UxmDnBfX4kc2pqgnmiJ4+zxGztnIRQi5FF/NCqWdiwyWBcqV2SmZEqs/CBdzyhoSXOWXp5sw==",
"dev": true, "dev": true,
"requires": { "requires": {
"open": "^8.4.0", "open": "^8.4.0",
...@@ -9433,9 +9433,9 @@ ...@@ -9433,9 +9433,9 @@
} }
}, },
"@koishijs/plugin-sandbox": { "@koishijs/plugin-sandbox": {
"version": "2.2.9", "version": "2.3.3",
"resolved": "https://registry.npmjs.org/@koishijs/plugin-sandbox/-/plugin-sandbox-2.2.9.tgz", "resolved": "https://registry.npmjs.org/@koishijs/plugin-sandbox/-/plugin-sandbox-2.3.3.tgz",
"integrity": "sha512-UOU3ZlM3Z5uW/Kd5rAsoxlACvvh8JqhPWl+nzCzu1FFptohU2vhaeHX9Hvp9d7iHppJ2JwHjSGK6Jw55yqQWjA==", "integrity": "sha512-I4b3BQcsjbiSIo4hzCCEN3zHS47E4ocqQ5NXt1nRmA9djKoEt76liK7Gs0klTjfJYLhoswZjfmYpoKjF1QLY8A==",
"dev": true, "dev": true,
"requires": {} "requires": {}
}, },
......
...@@ -182,11 +182,17 @@ export default class PicsContainer ...@@ -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://')) { if (url.startsWith('base64://')) {
return Buffer.from(url.slice(9), '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; 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