lib/oss.js
function (localFilePath) {
                let contentType = mime.lookup(localFilePath);
                let standerFilePath = localFilePath.replace(/\\/g, '/');
                fs.readFile(localFilePath, function (readFileErr, fileData) {
                    if (readFileErr) {
                        throw readFileErr;
                    }
                    const putConfig = {
                        Bucket: bucket.Name,
                        Body: fileData,
                        Key: standerFilePath,
                        ContentType: contentType,
                        AccessControlAllowOrigin: options.AccessControlAllowOrigin || '*',
                        CacheControl: options.CacheControl || 'no-cache',
                        Expires: options.Expires || null
                    };
                    if (options.contentEncoding) {
                        putConfig.ContentEncoding = options.contentEncoding;
                    }
                    oss.putObject(putConfig, function (putObjectErr) {
                        if (putObjectErr) {
                            console.error('error:', putObjectErr);
                            return putObjectErr;
                        }
                        console.log('upload success: ' + localFilePath);
                        if (bucketPaths.indexOf(standerFilePath) === -1) {
                            bucketPaths.push(standerFilePath);
                        }
                        if (localPaths.indexOf(standerFilePath) === -1) {
                            localPaths.push(standerFilePath);
                        }
                        //refresh cdn
                        if (options.oss.autoRefreshCDN && cdn) {
                            if (options.cdn.refreshQuota < 1) {
                                console.error('There is no refresh cdn url quota today.');
                                return;
                            }
                            let cdnDomain = '';
                            if (/^http/.test(options.cdn.domain)) {
                                cdnDomain = options.cdn.domain.replace(/^https?:?\/?\/?/, '');
                                options.cdn.secure === undefined && (options.cdn.secure = /^https/.test(options.cdn.domein));
                            }
                            else {
                                cdnDomain = options.cdn.domain;
                            }
                            let cdnObjectPath = url.format({
                                protocol: options.oss.secure ? 'https' : 'http',
                                hostname: cdnDomain,
                                pathname: standerFilePath
                            });
                            options.debug && console.log('Refreshing CDN file: ', cdnObjectPath);
                            cdn.refreshObjectCaches({
                                ObjectType: 'File',
                                ObjectPath: cdnObjectPath
                            }, function (refreshCDNErr) {
                                if (refreshCDNErr) {
                                    console.error('refresh cdn error: ', refreshCDNErr);
                                }
                                else {
                                    options.cdn.refreshQuota--;
                                    console.log('Refresh cdn file success: ', cdnObjectPath);
                                }
                            });
                        }
                    });
                });
            }
function (localFilePath) {
                let contentType = mime.lookup(localFilePath);
                let standerFilePath = localFilePath.replace(/\\/g, '/');
                fs.readFile(localFilePath, function (readFileErr, fileData) {
                    if (readFileErr) {
                        throw readFileErr;
                    }
                    const putConfig = {
                        Bucket: bucket.Name,
                        Body: fileData,
                        Key: standerFilePath,
                        ContentType: contentType,
                        AccessControlAllowOrigin: options.AccessControlAllowOrigin || '*',
                        CacheControl: options.CacheControl || 'no-cache',
                        Expires: options.Expires || null
                    };
                    if (options.contentEncoding) {
                        putConfig.ContentEncoding = options.contentEncoding;
                    }
                    oss.putObject(putConfig, function (putObjectErr) {
                        if (putObjectErr) {
                            console.error('error:', putObjectErr);
                            return putObjectErr;
                        }
                        console.log('upload success: ' + localFilePath);
                        if (bucketPaths.indexOf(standerFilePath) === -1) {
                            bucketPaths.push(standerFilePath);
                        }
                        if (localPaths.indexOf(standerFilePath) === -1) {
                            localPaths.push(standerFilePath);
                        }
                        //refresh cdn
                        if (options.oss.autoRefreshCDN && cdn) {
                            if (options.cdn.refreshQuota < 1) {
                                console.error('There is no refresh cdn url quota today.');
                                return;
                            }
                            let cdnDomain = '';
                            if (/^http/.test(options.cdn.domain)) {
                                cdnDomain = options.cdn.domain.replace(/^https?:?\/?\/?/, '');
                                options.cdn.secure === undefined && (options.cdn.secure = /^https/.test(options.cdn.domein));
                            }
                            else {
                                cdnDomain = options.cdn.domain;
                            }
                            let cdnObjectPath = url.format({
                                protocol: options.oss.secure ? 'https' : 'http',
                                hostname: cdnDomain,
                                pathname: standerFilePath
                            });
                            options.debug && console.log('Refreshing CDN file: ', cdnObjectPath);
                            cdn.refreshObjectCaches({
                                ObjectType: 'File',
                                ObjectPath: cdnObjectPath
                            }, function (refreshCDNErr) {
                                if (refreshCDNErr) {
                                    console.error('refresh cdn error: ', refreshCDNErr);
                                }
                                else {
                                    options.cdn.refreshQuota--;
                                    console.log('Refresh cdn file success: ', cdnObjectPath);
                                }
                            });
                        }
                    });
                });
            }
upload or update file function