Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
proto.get = async function get(name, file, options) {
let writeStream = null;
let needDestroy = false;
if (is.writableStream(file)) {
writeStream = file;
} else if (is.string(file)) {
writeStream = fs.createWriteStream(file);
needDestroy = true;
} else {
// get(name, options)
options = file;
}
options = options || {};
if (options.process) {
options.subres = options.subres || {};
options.subres['x-oss-process'] = options.process;
}
let result;
try {
const params = this._objectRequestParams('GET', name, options);
_onMessage(message) {
if (message && is.string(message.action)) {
debug('[%s] got message %s with %j, receiverPid: %s',
this.pid, message.action, message.data, message.receiverPid);
this.emit(message.action, message.data);
}
}
_onMessage(message) {
if (message && is.string(message.action)) {
debug('[%s] got message %s with %j', this.pid, message.action, message.data);
this.emit(message.action, message.data);
}
}
replacePort(str) {
if (!is.string(str)) return str;
return str.replace('{port}', this.app.config.assets.devServer.port);
}
function addPrefix(prefix, path) {
assert(is.string(path), `only support path with string, but got ${path}`);
return prefix + path;
}
proto._getFileSize = function* _getFileSize(file) {
if (is.buffer(file)) {
return file.length;
} else if (is.file(file)) {
return file.size;
} if (is.string(file)) {
var stat = yield this._statFile(file);
return stat.size;
}
throw new Error('_getFileSize requires Buffer/File/String.');
};
proto._getFileSize = async function _getFileSize(file) {
if (is.buffer(file)) {
return file.length;
} else if (is.blob(file) || is.file(file)) {
return file.size;
} if (is.string(file)) {
const stat = await this._statFile(file);
return stat.size;
}
throw new Error('_getFileSize requires Buffer/File/String.');
};
proto._getFileSize = function* _getFileSize(file) {
if (is.buffer(file)) {
return file.length;
} else if (is.file(file)) {
return file.size;
} if (is.string(file)) {
var stat = yield this._statFile(file);
return stat.size;
}
throw new Error('_getFileSize requires Buffer/File/String.');
};
proto._getFileSize = async function _getFileSize(file) {
if (is.buffer(file)) {
return file.length;
} else if (is.file(file)) {
return file.size;
} if (is.string(file)) {
const stat = await this._statFile(file);
return stat.size;
}
throw new Error('_getFileSize requires Buffer/File/String.');
};