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

djorm-storage-gcp

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

djorm-storage-gcp - npm Package Compare versions

Comparing version 0.1.18-alpha.1 to 0.1.19-alpha.0

43

index.js

@@ -1,21 +0,18 @@

const { Storage } = require('@google-cloud/storage')
const {
CharField,
FileStorage,
setSystemDefaultStorage
} = require('djorm/fields')
const { Storage: GcpStorage } = require('@google-cloud/storage')
const { Storage: DjormStorage } = require('djorm/storage/Storage')
class GcpFileStorage extends FileStorage {
static projectId = new CharField()
static clientEmail = new CharField()
static privateKey = new CharField()
static bucketName = new CharField()
static basePath = new CharField()
/** Google Cloud Platform Cloud Storage driver
* @param basePath {string} Prepend this path to all files
* @param bucketName {string} Bucket name
* @param clientEmail {string} The username / e-mail of the service account
* @param privateKey {string} The full private key
* @param projectId {string} The GCP project ID
*/
class GcpFileStorage extends DjormStorage {
get storage () {
return new Storage({
projectId: this.get('projectId'),
return new GcpStorage({
projectId: this.getProp('projectId'),
credentials: {
client_email: this.get('clientEmail'),
private_key: this.get('privateKey').replace(/\\n/g, '\n')
client_email: this.getProp('clientEmail'),
private_key: this.getProp('privateKey').replace(/\\n/g, '\n')
}

@@ -26,3 +23,3 @@ })

get bucket () {
return this.storage.bucket(this.bucketName)
return this.storage.bucket(this.getProp('bucketName'))
}

@@ -35,7 +32,7 @@

getReadStream (filePath) {
return this.file(filePath).getReadStream()
return this.file(filePath).createReadStream()
}
getWriteStream (filePath) {
return this.file(filePath).getWriteStream()
return this.file(filePath).createWriteStream()
}

@@ -62,6 +59,2 @@

function useAsDefault (props) {
setSystemDefaultStorage(new GcpFileStorage(props))
}
module.exports = { GcpFileStorage, useAsDefault }
module.exports = { GcpFileStorage }
{
"name": "djorm-storage-gcp",
"version": "0.1.18-alpha.1",
"version": "0.1.19-alpha.0",
"description": "Google Cloud Storage support for Djorm",
"author": "Pavel Žák <pavel@zak.global>",
"homepage": "https://github.com/just-paja/djorm#readme",
"homepage": "https://just-paja.github.io/djorm",
"license": "ISC",

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

"@google-cloud/storage": "^5.8.1",
"djorm": "^0.1.18-alpha.1"
"djorm": "^0.1.19-alpha.0"
},
"gitHead": "f3a01cf12213650617ae9a2c554776d9cb6a38d5"
"gitHead": "96cea85017466c1f3099c236f2e0a38623225629"
}
# `djorm-storage-gcp`
> TODO: description
> Google Cloud Platform storage driver for [Djorm](https://just-paja.github.io/djorm/)
## Usage
## Installation
```shell
npm install --save djorm-storage-gcp
```
const djormStorageGcp = require('djorm-storage-gcp');
// TODO: DEMONSTRATE API
## Configuration
```javascript
config({
storages: {
default: {
driver: 'djorm-storage-gcp.GcpFileStorage',
basePath: '',
bucketName: 'bucket-name',
clientEmail: 'serviceaccount@gcp.com',
privateKey: '### BEGIN PRIVATE KEY ...',
projectId: 'gcp-project-id',
}
}
})
```
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