Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

支持生成上传url #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

graysonchen
Copy link

客户端可以直接上传文件到upyun(而不先上传自己的主机再传到upyun)。

http://docs.upyun.com/api/form_api/

payload = {
policy: policy(base_opts.merge(opts)),
signature: signature,
url: "#{base_opts['save-key']}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cgg5207 请问这个 url 字段在哪里使用到了?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/upyun/ruby-sdk/pull/7/files#diff-04c6e90faac2675aa89e2176d2eec7d8R307
file_key 就是url, 只是为了与你们返回格式统一用。

POST https://v0.api.upyun.com/prepsmith

code: 200
message: "ok"
sign: "4cfa73b094e21f17534ef8b496719af1"
time: 1449827023
url: "6965706-19a16b00-4455-4a60-854f-38a5fdcb9449"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里上面用的是 merge 方法,而不是 merge!,所以 save-key 可能被 opts 给覆盖了.

@jsvisa
Copy link
Contributor

jsvisa commented Dec 10, 2015

@cgg5207 表单 API 上传支持,这是 UPYUN 服务端的特性,sdk 里面不需要额外的工作

客户端可以直接上传文件到upyun(而不先上传自己的主机再传到upyun)。

可能我没有理解你真正的需求,麻烦请描述详细点

@graysonchen
Copy link
Author

https://github.com/upyun/ruby-sdk/pull/7/files#diff-04c6e90faac2675aa89e2176d2eec7d8R317

客户直接在浏览器(chrome)上传文件到 UPYUN上,而不是先传到ruby webserver 然后再从ruby webserver上传到UPYUN,就是为了解决这个问题。

那么问题来了,不想把form-api-secret暴露在JS端上!

@graysonchen
Copy link
Author

https://github.com/aliyun-beta/aliyun-oss-ruby-sdk/blob/master/demo/app/views/home/new_post.html.erb

https://gist.github.com/huacnlee/3414491

@jsvisa

@jsvisa
Copy link
Contributor

jsvisa commented Dec 21, 2015

@cgg5207 sorry 这么晚才回复你,细看了一下你的回复,你是想直接在页面上生成一个文件上传到 UPYUN 的表单tag,这个 tag 里已经包含了经过 MD5 加密的 form-api-secret 信息,这样不会暴露细节给他人,用户只要直接点击后即可直接上传。

@graysonchen
Copy link
Author

是的!这个意思。

@jsvisa
Copy link
Contributor

jsvisa commented Dec 22, 2015

@cgg5207 谢谢您的反馈,稍后我将加上去(代码+测试+demo)

@graysonchen
Copy link
Author

nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants