new project: https://github.com/upyun/node-sdk
upyun / node-upyun Goto Github PK
View Code? Open in Web Editor NEWUPYUN Node.js SDK !!!Deprecated
License: MIT License
UPYUN Node.js SDK !!!Deprecated
License: MIT License
new project: https://github.com/upyun/node-sdk
uploadFile方法内,判断checksum有问题,如果传递checksum为false的话,下面代码的判断分支逻辑有错。
if(isFile && checksum === true) {
contentLength = fs.statSync(localFile).size;
utils.md5sumFile(localFile, function(err, result) {
opts['Content-MD5'] = result;
_upload(contentLength, opts);
});
} else if(isFile && typeof checksum === 'string') {
contentLength = fs.statSync(localFile).size;
opts['Content-MD5'] = checksum;
_upload(contentLength, opts);
} else {
contentLength = localFile.length;
opts['Content-MD5'] = utils.md5sum(localFile);
_upload(contentLength, opts);
}
我是这样写的
var upyun= new UPYUN('xxx', 'yyy', 'zzz', 'v0', 'legacy')
upyun.uploadFile(
'/write/src/'
,'./build/web-mobile/src/*'
,'folder'
,true
// ,[opts]
,(res, err)=>{
console.log(res, err)
}
)
返回给我的信息是这样的
null { statusCode: 200,
headers:
{ server: 'vivi/0.6',
'content-type': 'application/octet-stream',
'transfer-encoding': 'chunked',
connection: 'close',
'x-request-id': '465d625402e3115870462f769173140c',
date: 'Thu, 23 Jun 2016 02:21:10 GMT',
etag: '"2834b292750dac521d3b8b0a83a33e3b"',
'x-request-path': '403-zj-fud-200, ctn-hb-eez-200',
'x-error-code': '50300006',
'access-control-allow-origin': '*',
'x-vivi-streaming': 'on' },
data: {} }
但是在upyun manager客户端里看到write目录下只是多了一个无格式的src文件,点开write下原有的src目录里面也空了,手动在客户端里删掉那个无格式的src文件原来的src目录内容也正常了,求正确的folder上传姿势~
RT
before commit, should use standard --fix
to check it!
node-upyun git:(master) mocha
API Version:
✓ should return instance with legacy API
✓ should return instance with latest API
REST API:
getUsage(callback)
1) should return a result contains space and file
listDir(remotePath, callback)
2) should return a result contains files
createDir(remotePath, callback)
3) should return success code 201
removeDir(remotePath, callback)
4) should return 200
uploadFile(remotePath, localFile, type, checksum, [opts], callback)
5) should return the uploaded file's info
uploadFile(remotePath, localFile, type, checksum, [opts], callback)
6) should return the uploaded file's info
existsFile(remotePath, callback)
7) should return 200
downloadFile(remotePath, callback)
8) should return file's content
removeFile(remotePath, callback)
9) should return 200
Error handle
Sign error
10) should return sign error
No callback function
✓ should throw error
这个模块现在实在是不够好用,听说在准备重构?请问是否有考虑支持流式上传?
现在的版本是,如果用户上传一张图片,服务端进行中转的话,服务端需要存临时文件,或者存在内存里,再进行转发,这其实是很浪费资源的,希望能够支持流式上传,祝又拍云越做越好。
there are error log:
/node_modules/upyun/node_modules/upyun-legacy/index.js:60
var files = result.data.split('\n').reduce(function(prev, curr, idx, a
^
TypeError: Cannot call method 'split' of undefined`
每次上传文件之后我都写了一个接口发送请求更新文件缓存。
但是本地测试每次都是返回:
message: '
原始文件内容:
{
"type": "ui-button",
"name": "ui-button1-general",
"w": 200,
"h": 69,
"x": 151,
"y": 164,
"text": "你好",
"vTextAlign": "middle",
上传之后在浏览器打开查看:
{
"type": "ui-button",
"name": "ui-button1-general",
"w": 200,
"h": 69,
"x": 151,
"y": 164,
"text": "浣犲ソ",
"vTextAlign": "middle",
btw:
外链地址:http://lcbucket1.b0.upaiyun.com/filex1.txt
上传文件:Content-Type: 'text/plain'
checksum: true
希望帮忙看看,谢谢:)
调用uploadFile上传html文件,上传成功了,文件也在又拍云上了。里面的数据也是正确的。返回的数据中statusCode是200,但是data是{}.求解
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.