@@ -360,6 +360,7 @@ export interface CreateReadStreamOptions {
360360 validation ?: 'md5' | 'crc32c' | false | true ;
361361 start ?: number ;
362362 end ?: number ;
363+ decompress ?: boolean ;
363364}
364365
365366export interface SaveOptions extends CreateWriteStreamOptions { }
@@ -1120,6 +1121,10 @@ class File extends ServiceObject<File> {
11201121 * NOTE: Byte ranges are inclusive; that is, `options.start = 0` and
11211122 * `options.end = 999` represent the first 1000 bytes in a file or object.
11221123 * NOTE: when specifying a byte range, data integrity is not available.
1124+ * @property {boolean } [decompress=true] Disable auto decompression of the
1125+ * received data. By default this option is set to `true`.
1126+ * Applicable in cases where the data was uploaded with
1127+ * `gzip: true` option. See {@link File#createWriteStream}.
11231128 */
11241129 /**
11251130 * Create a readable stream to read the contents of the remote file. It can be
@@ -1192,6 +1197,7 @@ class File extends ServiceObject<File> {
11921197 * .pipe(fs.createWriteStream('/Users/stephen/logfile.txt'));
11931198 */
11941199 createReadStream ( options : CreateReadStreamOptions = { } ) : Readable {
1200+ options = Object . assign ( { decompress : true } , options ) ;
11951201 const rangeRequest =
11961202 typeof options . start === 'number' || typeof options . end === 'number' ;
11971203 const tailRequest = options . end ! < 0 ;
@@ -1312,7 +1318,7 @@ class File extends ServiceObject<File> {
13121318 throughStreams . push ( validateStream ) ;
13131319 }
13141320
1315- if ( isCompressed ) {
1321+ if ( isCompressed && options . decompress ) {
13161322 throughStreams . push ( zlib . createGunzip ( ) ) ;
13171323 }
13181324
0 commit comments