Skip to content

fix fetch uphosts bug #185

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

Merged
merged 1 commit into from
Oct 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions dist/qiniu.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*!
* qiniu-js-sdk v1.0.17-beta
* qiniu-js-sdk v1.0.17.1
*
* Copyright 2015 by Qiniu
* Released under GPL V2 License.
*
* GitHub: http://github.com/qiniu/js-sdk
*
* Date: 2016-9-30
* Date: 2016-10-11
*/

/*global plupload ,mOxie*/
Expand Down Expand Up @@ -595,14 +595,25 @@ function QiniuJsSDK() {
return result;
};

var getUpHosts = function(uptoken) {
var getPutPolicy = function (uptoken) {
var segments = uptoken.split(":");
var ak = segments[0];
var putPolicy = that.parseJSON(that.URLSafeBase64Decode(segments[2]));
putPolicy.ak = ak;
if (putPolicy.scope.indexOf(":") >= 0) {
putPolicy.bucket = putPolicy.scope.split(":")[0];
putPolicy.key = putPolicy.scope.split(":")[1];
} else {
putPolicy.bucket = putPolicy.scope;
}
return putPolicy;
};

var getUpHosts = function(uptoken) {
var putPolicy = getPutPolicy(uptoken);
// var uphosts_url = "//uc.qbox.me/v1/query?ak="+ak+"&bucket="+putPolicy.scope;
// IE 9- is not support protocal relative url
var uphosts_url = window.location.protocol + "//uc.qbox.me/v1/query?ak="+ak+"&bucket="+putPolicy.scope;
logger.debug("ak: ", ak);
var uphosts_url = window.location.protocol + "//uc.qbox.me/v1/query?ak=" + putPolicy.ak + "&bucket=" + putPolicy.bucket;
logger.debug("putPolicy: ", putPolicy);
logger.debug("get uphosts from: ", uphosts_url);
var ie = that.detectIEVersion();
Expand Down Expand Up @@ -718,7 +729,15 @@ function QiniuJsSDK() {

// get file key according with the user passed options
var getFileKey = function(up, file, func) {
// TODO: save_key can read from scope of token
// WARNING
// When you set the key in putPolicy by "scope": "bucket:key"
// You should understand the risk of override a file in the bucket
// So the code below that automatically get key from uptoken has been commented
// var putPolicy = getPutPolicy(that.token)
// if (putPolicy.key) {
// logger.debug("key is defined in putPolicy.scope: ", putPolicy.key)
// return putPolicy.key
// }
var key = '',
unique_names = false;
if (!op.save_key) {
Expand Down Expand Up @@ -923,7 +942,6 @@ function QiniuJsSDK() {
}
}


up.setOption({
'url': qiniuUploadUrl,
'multipart': true,
Expand Down
Loading