add sync download
This commit is contained in:
@@ -3,9 +3,11 @@ import { baseURL, storage } from '@/module/query.ts';
|
||||
import { upload } from '@/module/download/upload.ts';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
import { getHash, getBufferHash } from '@/uitls/hash.ts';
|
||||
import { logger } from '@/module/logger.ts';
|
||||
const scriptPath = path.join(process.cwd(), 'src', 'scripts');
|
||||
const sum = 'https://kevisual.xiongxiao.me/root/ai/kevisual/01-summary.md';
|
||||
const sum2 = 'https://kevisual.xiongxiao.me/root/resources/ai/1.0.0/kevisual/01-summary.md';
|
||||
const download = async () => {
|
||||
const { content } = await fetchLink(sum, { returnContent: true });
|
||||
console.log(content.toString());
|
||||
@@ -16,9 +18,28 @@ const download = async () => {
|
||||
const uploadTest = async () => {
|
||||
const file = fs.readFileSync(path.join(scriptPath, './summary.md'));
|
||||
const token = storage.getItem('token');
|
||||
const url = new URL(sum);
|
||||
// const res = await upload({ url: sum, file: '# 汇总 123', token });
|
||||
const res = await upload({ url: sum, file: file, token });
|
||||
console.log(res);
|
||||
url.searchParams.append('force', 'true');
|
||||
// url.searchParams.append('meta', encodeURIComponent(JSON.stringify({ m: 'meta-test' })));
|
||||
const res = await upload({ url: url, file: file, token, needHash: true });
|
||||
logger.info('上传成功', res);
|
||||
};
|
||||
|
||||
uploadTest();
|
||||
const hashCheck = () => {
|
||||
const filepath = path.join(scriptPath, './summary.md');
|
||||
const file = fs.readFileSync(filepath);
|
||||
console.log(getHash(filepath));
|
||||
console.log(getBufferHash(file));
|
||||
};
|
||||
|
||||
// hashCheck();
|
||||
|
||||
// const buf = Buffer.from('123');
|
||||
// const abc = {
|
||||
// a: 1,
|
||||
// b: 2,
|
||||
// c: 3,
|
||||
// };
|
||||
// console.log(typeof buf, buf instanceof Buffer, abc instanceof Buffer);
|
||||
|
||||
Reference in New Issue
Block a user