Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

akos-egg-nos

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

akos-egg-nos - npm Package Compare versions

Comparing version 1.0.14 to 1.0.15

65

lib/loader.js

@@ -7,2 +7,3 @@ 'use strict';

const crypto = require('crypto');
const intoStream = require('into-stream');
module.exports = app => {

@@ -28,11 +29,45 @@ const defaultConfig = {

return nosClient;
}
};
const nosClient = app.nos.loadNosClient(Object.assign({}, defaultConfig, config));
app.nos.uploadText = async function uploadFile(key, content, hash) {
const config = app.config.nos;
if (hash) { // 给文件带 hash
const ext = path.extname(key);
const basename = path.basename(key, ext);
key = `${basename}_${uuid.v4().replace(/-/g, '')}${ext}`;
}
const result = await new Promise((resolve, reject) => {
try {
nosClient.put_object_stream(Object.assign({
bucket: config.bucket,
key,
body: intoStream(content),
length: content.length,
}), result => {
result.bucket = config.bucket;
result.endpoint = config.endpoint;
result.port = config.port;
result.key = key;
if (result.statusCode === 200) {
resolve(result);
} else {
resolve(result);
}
});
} catch (err) {
app.logger.error(err);
reject(err);
}
});
return result;
};
app.nos.uploadFile = async function uploadFile(filepath, key, hash) {
const config = app.config.nos;
if (!key)
key = path.basename(filepath);
if (!key) { key = path.basename(filepath); }
if (hash) { // 给文件带 hash

@@ -47,15 +82,15 @@ const ext = path.extname(key);

nosClient.put_file(Object.assign({
bucket: config.bucket,
key,
filepath,
bucket: config.bucket,
key,
filepath,
}), result => {
result.bucket = config.bucket;
result.endpoint = config.endpoint;
result.port = config.port;
result.key = key;
if (result.statusCode === 200) {
resolve(result);
} else {
resolve(result);
}
result.bucket = config.bucket;
result.endpoint = config.endpoint;
result.port = config.port;
result.key = key;
if (result.statusCode === 200) {
resolve(result);
} else {
resolve(result);
}
});

@@ -62,0 +97,0 @@ } catch (err) {

{
"name": "akos-egg-nos",
"version": "1.0.14",
"version": "1.0.15",
"description": "[![NPM version][npm-image]][npm-url] [![build status][travis-image]][travis-url] [![Test coverage][codecov-image]][codecov-url] [![David deps][david-image]][david-url] [![Known Vulnerabilities][snyk-image]][snyk-url] [![npm download][download-image]][download-url]",

@@ -15,2 +15,3 @@ "eggPlugin": {

"dependencies": {
"into-stream": "^5.1.1",
"nos-node-sdk": "^0.0.5",

@@ -17,0 +18,0 @@ "uuid": "^3.4.0"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc