-
Notifications
You must be signed in to change notification settings - Fork 598
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
storage: getSigned*: clear up expiration format #835
Conversation
@@ -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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
719b2f5
to
412b4e9
Compare
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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
412b4e9
to
432777e
Compare
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? |
…correction storage: getSigned*: clear up expiration format
Sure, that sounds like a good plan. |
Fixes #834
Formerly:
getSignedPolicy
- options.expiration - Advertised as seconds, handled by our code as millisecondsgetSignedUrl
- options.expires - Advertised as seconds, handled by the API directly as secondsNow:
getSignedPolicy
- options.expires - Advertised as anything Date acceptsgetSignedUrl
- options.expires - Advertised as anything Date acceptsAlso added a system test for getSignedPolicy, which we didn't have previously.