-
Notifications
You must be signed in to change notification settings - Fork 578
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support callback options for put and multipartUpload (#379)
* test: support callback server * test: change test name * test: add browser callback case * feat: add case callbackServer doc * fix: multipartUpload and multipartUploadCopy callback * feat: support callback and callbackVar options to put and multipartUpload * feat: review code fix * feat: modify callback readme Close #85
- Loading branch information
1 parent
e42a534
commit 46c8dec
Showing
13 changed files
with
349 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
'use strict'; | ||
|
||
|
||
exports.encodeCallback = function(options) { | ||
options.headers = options.headers || {}; | ||
if (!options.headers.hasOwnProperty('x-oss-callback')) { | ||
if (options.callback) { | ||
var json = { | ||
callbackUrl: encodeURI(options.callback.url), | ||
callbackBody: options.callback.body | ||
}; | ||
if (options.callback.host) { | ||
json.callbackHost = options.callback.host; | ||
} | ||
if (options.callback.contentType) { | ||
json.callbackBodyType = options.callback.contentType; | ||
} | ||
var callback = new Buffer(JSON.stringify(json)).toString('base64'); | ||
options.headers['x-oss-callback'] = callback; | ||
|
||
if (options.callback.customValue) { | ||
var callbackVar = {}; | ||
for (var key in options.callback.customValue) { | ||
callbackVar['x:' + key] = options.callback.customValue[key]; | ||
} | ||
options.headers['x-oss-callback-var'] = new Buffer(JSON.stringify(callbackVar)).toString('base64'); | ||
} | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.