Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@infurnia/backend-file-storage

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@infurnia/backend-file-storage - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

29

index.js

@@ -52,4 +52,4 @@ const utils = require('./utils');

try{
let files_list = await gcs_client.list_files_in_bucket(this.bucket_name, directory);
return files_list[0].map(x=> x.name);
let files_list = await this.gcs_client.list_files_in_bucket(this.bucket_name, directory);
return files_list[0];
}

@@ -68,3 +68,3 @@ catch(err){

destinationPath = clean_file_path(destinationPath);
await gcs_client.write_file_from_path_to_bucket(this.bucket_name, destinationPath, sourcePath);
await this.gcs_client.write_file_from_path_to_bucket(this.bucket_name, destinationPath, sourcePath);
if (deleteSourceFileAfterUpload===true) {

@@ -90,3 +90,3 @@ await fs_promises.rm(sourcePath);

destinationPath = clean_file_path(destinationPath);
await gcs_client.write_file_obj_to_bucket(this.bucket_name, destinationPath, object);
await this.gcs_client.write_file_obj_to_bucket(this.bucket_name, destinationPath, object);
return OK_RESPONSE_TEXT;

@@ -105,3 +105,3 @@ }

filePath = clean_file_path(filePath);
return await gcs_client.get_write_stream_for_bucket(this.bucket_name, filePath);
return await this.gcs_client.get_write_stream_for_bucket(this.bucket_name, filePath);
}

@@ -123,3 +123,3 @@ catch(err){

//check if the key exists
let response = await gcs_client.check_if_file_exists(
let response = await this.gcs_client.check_if_file_exists(
this.bucket_name,

@@ -144,3 +144,3 @@ filePath

//copy the file
await gcs_client.copy(this.bucket_name, sourceFilePath, this.bucket_name, destFilePath);
await this.gcs_client.copy(this.bucket_name, sourceFilePath, this.bucket_name, destFilePath);
return OK_RESPONSE_TEXT;

@@ -159,3 +159,3 @@ }

filePath = clean_file_path(filePath);
return (await gcs_client.read_file(this.bucket_name, filePath)).toString('utf-8');
return (await this.gcs_client.read_file(this.bucket_name, filePath)).toString('utf-8');
}

@@ -168,2 +168,15 @@ catch(err){

}
//gets a signed url for an object with read permission
getSignedUrl = async(filePath) => {
try{
filePath = clean_file_path(filePath);
return await this.gcs_client.get_signed_url(this.bucket_name, filePath, 'read');
}
catch(err){
console.error(`error in file_storage/index.js/getSignedUrl`);
console.error(err);
throw err;
}
}
}

@@ -170,0 +183,0 @@

@@ -100,4 +100,22 @@ const {Storage} = require('@google-cloud/storage');

}
//get signed url
get_signed_url = async(bucket_name, key, permission='read', expiry_in_secs=180) => {
try{
if (!bucket_name) throw new Error(`bucket_name must be specified`);
if (!key) throw new Error(`key must be specified`);
if (permission!='read' && permission!='write') {
throw new Error(`permission level ${permission} is not supported, must be one of ['read', 'write']`);
}
const gcs_file = this.gcsClient.bucket(bucket_name).file(key);
const res = await gcs_file.getSignedUrl({action: permission, expires: expiry_in_secs});
return res[0];
}
catch(err){
console.error(err);
throw err;
}
}
}
module.exports = InfurniaGCSClient;
{
"name": "@infurnia/backend-file-storage",
"version": "2.1.0",
"version": "2.2.0",
"description": "Storage engine for google cloud storage",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc