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

storage: getSigned*: clear up expiration format #835

Conversation

stephenplusplus
Copy link
Contributor

Fixes #834

Formerly:

getSignedPolicy - options.expiration - Advertised as seconds, handled by our code as milliseconds
getSignedUrl - options.expires - Advertised as seconds, handled by the API directly as seconds

Now:

getSignedPolicy - options.expires - Advertised as anything Date accepts
getSignedUrl - options.expires - Advertised as anything Date accepts

Also added a system test for getSignedPolicy, which we didn't have previously.

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Aug 30, 2015
@stephenplusplus stephenplusplus added the api: storage Issues related to the Cloud Storage API. label Aug 30, 2015
@@ -932,22 +932,29 @@ File.prototype.getMetadata = function(callback) {
* @param {object} callback.policy - The document policy.
*
* @example
* file.getSignedPolicy({
* var TWO_WEEKS_FROM_NOW = Math.round(Date.now() / 1000) + (60 * 60 * 24 * 14);

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@jgeewax
Copy link
Contributor

jgeewax commented Aug 30, 2015

LGTM

* @param {array|array[]=} options.equals - Array of request parameters and
* their expected value (e.g. [['$<field>', '<value>']]). Values are
* translated into equality constraints in the conditions field of the
* policy document (e.g. ['eq', '$<field>', '<value>']). If only one
* equality condition is to be specified, options.equals can be a one-
* dimensional array (e.g. ['$<field>', '<value>']).
* @param {object} options.expires - Timestamp (seconds since epoch) when this

This comment was marked as spam.

This comment was marked as spam.

@stephenplusplus stephenplusplus force-pushed the spp--storage-expiration-correction branch from 719b2f5 to 412b4e9 Compare August 31, 2015 13:46
@stephenplusplus
Copy link
Contributor Author

Updated to accept anything Date accepts.

var expires = new Date(options.expires).getTime();
var expiresInSeconds = Math.round(expires / 1000); // The API expects seconds.

if (expires < Date.now()) {

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@stephenplusplus stephenplusplus force-pushed the spp--storage-expiration-correction branch from 412b4e9 to 432777e Compare August 31, 2015 17:14
@stephenplusplus
Copy link
Contributor Author

The docs test timed out after 2s. I restarted travis, it failed. Restarted again and it passed. Maybe that needs to be bumped up? Wait til it consistently becomes an issue?

callmehiphop added a commit that referenced this pull request Aug 31, 2015
…correction

storage: getSigned*: clear up expiration format
@callmehiphop callmehiphop merged commit a4a19b8 into googleapis:master Aug 31, 2015
@callmehiphop
Copy link
Contributor

Sure, that sounds like a good plan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the Cloud Storage API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants