ufilesdk-dev / ufile-gosdk Goto Github PK
View Code? Open in Web Editor NEWUCloud 对象存储官方 SDK
Home Page: https://www.ucloud.cn/
License: Apache License 2.0
UCloud 对象存储官方 SDK
Home Page: https://www.ucloud.cn/
License: Apache License 2.0
hi ,你好!
mac上编译后上传文件没问题,但在mac上交叉编译后在linux系统上传文件报错 Remote response code is 404 - Not Found not 2xx call DumpResponse(true) show details
Hi,
Can you add a license to your project? Or let me know what the license is if I have missed that info somewhere.
Thank you,
Ariel
在file.go中,只有一个Download函数,该函数只是发起一个http请求,请提供能将baody数据直接存放到文件中的函数,比如:Download(localFileName, fileKey string)
I created an UFileRequest with:
header = http.Header{
"Range": []string{fmt.Sprintf("bytes=%d-%d", 0, 25)},
}
req = helper.NewFileRequest(BucketName, header)
But when I called:
err = req.DownloadFile(io.Discard, fileName)
I found that the header wasn't in the underlying http request.
从代码看,目前不支持https,有计划支持https吗?
问题描述:
调用函数DownloadFile下载文件时,运行到行 err := u.HeadFile(keyName) 出错。错误内容:Remote response code is 403 - Forbidden not 2xx call DumpResponse(true) show details%!(EXTRA string=HTTP/1.1 403
X-Sessionid: 95f34139-862d-4c4f-a8ac-1bb0af6c675fServer: nginx/1.11.1Date: Tue, 30 Oct 2018 11:22:42 GMTContent-Type: application/jsonContent-Length: 53Connection: keep-aliveVary: Origin)
传入的参数:keyName= “/data/a/b/c.txt”
试图解决:
运行demo_downloadfile.go,如果使用默认文件名称,完全正确。如果将文件名称替换为:"/data/a/b/c.txt",在运行到PutFile函数时,报错:HTTP/1.1 403
Content-Type: application/jsonContent-Length: 53Connection: keep-aliveX-Sessionid: d7ce59c2-80bd-45d9-93d8-45408a8aadb3Server: nginx/1.11.1Date: Tue, 30 Oct 2018 11:27:07 GMT{ "RetCode": -148658, "ErrMsg": "invalid signature" }
初步判定原因:keyName以'/'开始,服务端验证签名失败。
疑问:为什么以'/'开始,导致403?请针对这种情况修正一下代码。
We are planning to support ucloud file sdk (see go-gitea/gitea#15937). Could you add some English documentation so that more contributions could work with it?
使用mput 接口时. 报错 Post http://vdplay.ufile.ucloud.com.cn/zmg182x78q.mp4?uploads: EOF
代码 : err = req.MPut(localFileName, keyName, "")
Would you like to add a license for your project?
请问各个接口是否已经测试过,我这里出现以下问题。
调用file.go中接口PrefixFileList出现403错误,具体错误:{ "RetCode": -148658, "ErrMsg": "invalid signature" }。
但是,使用同样的公私钥配置,利用“管理工具filemgr-linux64”可以获取到文件列表。
请看看是不是生成signature的方式有问题。谢谢!
Fragment upload does not consume body, resulting in http1.1 connection not being reused
业务场景:
前端 ----> 上传文件 -----> 应用服务 -------> 对象存储
目前 sdk,貌似只支持本地文件上传,即是应用服务需要自己实现一次文件上传保存到本地,再上传到对象存储.
不支持应用服务做中转这样的吗,即应用服务不用把文件存放在本地.
@leyafo 函数UploadPart中,
resp, err := u.requestWithResp(req)
未调用resp.Body.Close()
导致内存泄漏
相关代码如下:
func (u *UFileRequest) DownloadFile(writer io.Writer, keyName string) error {
reqURL := u.GetPrivateURL(keyName, 24*time.Hour)
req, err := http.NewRequest("GET", reqURL, nil)
if err != nil {
return err
}
resp, err := u.requestWithResp(req)
if err != nil {
return err
}
defer resp.Body.Close()
u.LastResponseStatus = resp.StatusCode
u.LastResponseHeader = resp.Header
u.LastResponseBody = nil //流式下载无body存储在u里
u.lastResponse = resp
if !VerifyHTTPCode(resp.StatusCode) {
return fmt.Errorf("Remote response code is %d - %s not 2xx call DumpResponse(true) show details",
resp.StatusCode, http.StatusText(resp.StatusCode))
}
size := u.LastResponseHeader.Get("Content-Length")
fileSize, err := strconv.ParseInt(size, 10, 0)
if err != nil || fileSize < 0 {
return fmt.Errorf("Parse content-lengt returned error")
}
_, err = io.Copy(writer, resp.Body)
return err
}
由于size := u.LastResponseHeader.Get("Content-Length")
获取不到 length 导致后续 _, err = io.Copy(writer, resp.Body)
没执行,下载文件失败。
请确认是新版API不返回 Length 属性了?还是 SDK 需要更新
地址: https://console.ucloud.cn/ufile/tools
最下面没有 go SDK的图标显示,会让人以为没有,其实在github中是有的,建议加上图标显示
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.