@ifonts/qiniu-file-upload
v1.1.2
Published
qiniu file upload tool
Downloads
3
Readme
@ifonts/qiniu-file-upload
This script uploads a directory of files to a specified Qiniu cloud storage bucket. It uses the qiniu library to handle the uploads and supports options for concurrency, ignoring specific files, and custom log handling.
Prerequisites
- Node.js
- Qiniu account with access keys
Install
$ npm install @ifonts/qiniu-file-upload
Example
require('dotenv').config();
const path = require('path');
const { uploadDir } = require('./qiniu-upload');
uploadDir({
dir: path.join(__dirname, './public/images'),
keyPrefix: '/images',
bucket: 'bucket-oss',
accessKey: process.env.ACCESS_KEY,
secretKey: process.env.SECRET_KEY
});
Options
dir
: The local directory to upload.bucket
: The target Qiniu bucket name.keyPrefix
(optional): The prefix to prepend to all keys in the bucket.accessKey
: Your Qiniu access key (optional if already configured).secretKey
: Your Qiniu secret key (optional if already configured).ignoreFilenames
(optional): Array of filenames to ignore during upload (default: [".DS_Store"]).overwrite
(optional): boolean to force overwrite all files (default: false).overwrites
(optional): Array of strings or regular expressions to force overwrite specific files whenoverwrite
is false.concurrency
(optional): Number of concurrent uploads (default: 6).onLog
(optional): Callback function to handle log messages.