mirror of
https://gitcode.com/github-mirrors/react-native-update-cli.git
synced 2025-09-16 09:41:38 +08:00
Show current filesize
This commit is contained in:
10
src/api.js
10
src/api.js
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
const fetch = require('node-fetch');
|
||||
const defaultEndpoint = 'http://u.reactnative.cn/api'
|
||||
const defaultEndpoint = 'http://u.reactnative.cn/api';
|
||||
let host = process.env.PUSHY_REGISTRY || defaultEndpoint;
|
||||
const fs = require('fs');
|
||||
import request from 'request';
|
||||
@@ -107,7 +107,7 @@ exports.doDelete = queryWithBody('DELETE');
|
||||
|
||||
async function uploadFile(fn, key) {
|
||||
const { url, backupUrl, formData, maxSize } = await exports.post('/upload', {
|
||||
ext: path.extname(fn)
|
||||
ext: path.extname(fn),
|
||||
});
|
||||
let realUrl = url;
|
||||
|
||||
@@ -126,7 +126,11 @@ async function uploadFile(fn, key) {
|
||||
|
||||
const fileSize = fs.statSync(fn).size;
|
||||
if (maxSize && fileSize > filesizeParser(maxSize)) {
|
||||
throw new Error(`此文件大小超出上限${maxSize}。您可以考虑升级付费业务以提升此限制。详情请访问:${pricingPageUrl}`)
|
||||
throw new Error(
|
||||
`此文件大小${(fileSize / 1048576).toFixed(
|
||||
1,
|
||||
)}m, 超出当前额度${maxSize}。您可以考虑升级付费业务以提升此额度。详情请访问:${pricingPageUrl}`,
|
||||
);
|
||||
}
|
||||
|
||||
const bar = new ProgressBar(' Uploading [:bar] :percent :etas', {
|
||||
|
Reference in New Issue
Block a user