File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1173,6 +1173,7 @@ File.prototype.getSignedUrl = function(options, callback) {
11731173 } [ options . action ] ;
11741174
11751175 var name = encodeURIComponent ( this . name ) ;
1176+ var targetGeneration = this . generation ;
11761177
11771178 options . resource = '/' + this . bucket . name + '/' + name ;
11781179
@@ -1221,13 +1222,19 @@ File.prototype.getSignedUrl = function(options, callback) {
12211222 encodeURIComponent ( options . responseDisposition ) ;
12221223 }
12231224
1225+ var generation = '' ;
1226+ if ( ! is . undefined ( targetGeneration ) ) {
1227+ generation = '&generation=' + targetGeneration ;
1228+ }
1229+
12241230 callback ( null , [
12251231 'https://storage.googleapis.com' + options . resource ,
12261232 '?GoogleAccessId=' + credentials . client_email ,
12271233 '&Expires=' + expiresInSeconds ,
12281234 '&Signature=' + encodeURIComponent ( signature ) ,
12291235 responseContentType ,
1230- responseContentDisposition
1236+ responseContentDisposition ,
1237+ generation
12311238 ] . join ( '' ) ) ;
12321239 } ) ;
12331240} ;
Original file line number Diff line number Diff line change @@ -1749,6 +1749,18 @@ describe('File', function() {
17491749 } ) ;
17501750 } ) ;
17511751
1752+ it ( 'should add generation parameter' , function ( done ) {
1753+ var generation = 10003320000 ;
1754+ var file = new File ( BUCKET , 'name' , { generation : generation } ) ;
1755+ file . getSignedUrl ( {
1756+ action : 'read' ,
1757+ expires : Date . now ( ) + 5 ,
1758+ } , function ( err , signedUrl ) {
1759+ assert ( signedUrl . indexOf ( encodeURIComponent ( generation ) ) > - 1 ) ;
1760+ done ( ) ;
1761+ } ) ;
1762+ } ) ;
1763+
17521764 describe ( 'promptSaveAs' , function ( ) {
17531765 it ( 'should add response-content-disposition' , function ( done ) {
17541766 var disposition = 'attachment; filename="fname.ext"' ;
You can’t perform that action at this time.
0 commit comments