@rytass/storages-adapter-gcs 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs.js CHANGED
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var storages = require('@rytass/storages');
6
4
  var stream = require('stream');
7
5
  var uuid = require('uuid');
8
6
  var storage = require('@google-cloud/storage');
9
7
 
10
8
  class StorageGCSService extends storages.Storage {
9
+ storage;
10
+ bucket;
11
11
  constructor(options){
12
12
  super(options);
13
13
  this.storage = new storage.Storage({
@@ -62,18 +62,18 @@ class StorageGCSService extends storages.Storage {
62
62
  const uploadStream = new stream.PassThrough();
63
63
  const getFilenamePromise = this.getStreamFilename(stream$1);
64
64
  const tempFile = this.bucket.file(tempFilename);
65
- const writeStream1 = tempFile.createWriteStream({
65
+ const writeStream = tempFile.createWriteStream({
66
66
  gzip: 'auto',
67
67
  ...options?.contentType ? {
68
68
  contentType: options?.contentType
69
69
  } : {}
70
70
  });
71
- stream$1.pipe(uploadStream).pipe(writeStream1);
71
+ stream$1.pipe(uploadStream).pipe(writeStream);
72
72
  const [[filename, mime]] = await Promise.all([
73
73
  getFilenamePromise,
74
74
  new Promise((resolve)=>{
75
- writeStream1.on('finish', resolve);
76
- }),
75
+ writeStream.on('finish', resolve);
76
+ })
77
77
  ]);
78
78
  if (!options?.contentType && mime) {
79
79
  await tempFile.setMetadata({
@@ -92,7 +92,7 @@ class StorageGCSService extends storages.Storage {
92
92
  await file.save(buffer, {
93
93
  gzip: 'auto',
94
94
  ...Array.isArray(fileInfo) && fileInfo[1] ? {
95
- ContentType: fileInfo[1]
95
+ contentType: fileInfo[1]
96
96
  } : {},
97
97
  ...options?.contentType ? {
98
98
  contentType: options?.contentType
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rytass/storages-adapter-gcs",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Google Cloud Storage Adapter for @rytass/storages",
5
5
  "keywords": [
6
6
  "gcp",
@@ -21,7 +21,7 @@
21
21
  "url": "https://github.com/Rytass/Utils/issues"
22
22
  },
23
23
  "dependencies": {
24
- "@google-cloud/storage": "^6.9.3",
24
+ "@google-cloud/storage": "^6.10.1",
25
25
  "@rytass/storages": "^0.2.0",
26
26
  "uuid": "^9.0.0"
27
27
  },
@@ -4,6 +4,8 @@ import { v4 } from 'uuid';
4
4
  import { Storage as Storage$1 } from '@google-cloud/storage';
5
5
 
6
6
  class StorageGCSService extends Storage {
7
+ storage;
8
+ bucket;
7
9
  constructor(options){
8
10
  super(options);
9
11
  this.storage = new Storage$1({
@@ -58,18 +60,18 @@ class StorageGCSService extends Storage {
58
60
  const uploadStream = new PassThrough();
59
61
  const getFilenamePromise = this.getStreamFilename(stream);
60
62
  const tempFile = this.bucket.file(tempFilename);
61
- const writeStream1 = tempFile.createWriteStream({
63
+ const writeStream = tempFile.createWriteStream({
62
64
  gzip: 'auto',
63
65
  ...options?.contentType ? {
64
66
  contentType: options?.contentType
65
67
  } : {}
66
68
  });
67
- stream.pipe(uploadStream).pipe(writeStream1);
69
+ stream.pipe(uploadStream).pipe(writeStream);
68
70
  const [[filename, mime]] = await Promise.all([
69
71
  getFilenamePromise,
70
72
  new Promise((resolve)=>{
71
- writeStream1.on('finish', resolve);
72
- }),
73
+ writeStream.on('finish', resolve);
74
+ })
73
75
  ]);
74
76
  if (!options?.contentType && mime) {
75
77
  await tempFile.setMetadata({
@@ -88,7 +90,7 @@ class StorageGCSService extends Storage {
88
90
  await file.save(buffer, {
89
91
  gzip: 'auto',
90
92
  ...Array.isArray(fileInfo) && fileInfo[1] ? {
91
- ContentType: fileInfo[1]
93
+ contentType: fileInfo[1]
92
94
  } : {},
93
95
  ...options?.contentType ? {
94
96
  contentType: options?.contentType