@infurnia/backend-file-storage
Advanced tools
Comparing version 2.12.0 to 2.13.0
14
index.js
@@ -163,2 +163,16 @@ const utils = require('./utils'); | ||
//downloads gcs object as a file | ||
downloadFile = async(sourceFilePath, destFilePath) => { | ||
try{ | ||
sourceFilePath = clean_file_path(sourceFilePath, false); | ||
console.debug(sourceFilePath, destFilePath); | ||
return (await this.gcs_client.download_file(this.bucket_name, sourceFilePath, destFilePath)); | ||
} | ||
catch(err){ | ||
console.error(`error in file_storage/index.js/downloadFile`); | ||
console.error(err); | ||
throw err; | ||
} | ||
} | ||
//gets a signed url for an object with read permission | ||
@@ -165,0 +179,0 @@ getSignedUrl = async(filePath) => { |
@@ -117,2 +117,17 @@ const {Storage} = require('@google-cloud/storage'); | ||
//read file contents | ||
download_file = async(bucket_name, key, destination_path) => { | ||
try{ | ||
if (!bucket_name) throw new Error(`bucket_name must be specified`); | ||
if (!key) throw new Error(`key must be specified`); | ||
const gcs_file = this.gcsClient.bucket(bucket_name).file(key); | ||
await gcs_file.download({ destination: destination_path}); | ||
return "OK"; | ||
} | ||
catch(err){ | ||
console.error(err); | ||
throw err; | ||
} | ||
} | ||
//get signed url | ||
@@ -119,0 +134,0 @@ get_signed_url = async(bucket_name, key, permission='read', expiry_in_secs=600) => { |
{ | ||
"name": "@infurnia/backend-file-storage", | ||
"version": "2.12.0", | ||
"version": "2.13.0", | ||
"description": "Storage engine for google cloud storage", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16811
371