21 lines
636 B
TypeScript
21 lines
636 B
TypeScript
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import { nocoApi } from './common';
|
|
import util from 'node:util';
|
|
const filePath = path.resolve(process.cwd(), 'public/mole.png');
|
|
const absolutePath = path.resolve(process.cwd(), filePath);
|
|
const fileBuffer = fs.readFileSync(absolutePath);
|
|
const blob = new Blob([fileBuffer], { type: 'image/png' });
|
|
|
|
const res = await nocoApi.upload.createUpload({
|
|
file: blob,
|
|
title: 'mole3.png',
|
|
})
|
|
console.log('上传结果:');
|
|
console.log(util.inspect(res, { depth: null }));
|
|
// const update = await nocoApi.record.update({
|
|
// Id: 4,
|
|
// Picture: res.list
|
|
// })
|
|
|
|
// console.log(update)
|