UNPKG

mt-music-player

Version:

A simply web music player app.

23 lines (19 loc) 545 B
import upyun from 'upyun'; import config from 'config'; import crypto from 'crypto'; const service = new upyun.Service( config.get('upyun.name'), config.get('upyun.operator'), config.get('upyun.password'), ); const client = new upyun.Client(service); export default { async putFile(file, option) { const hash = crypto.createHash('sha256'); hash.update(file); const path = hash.digest('hex'); const exist = await client.headFile(path); if (!exist) await client.putFile(path, file, option); return path; }, };