Storage
Class: Storage<T>
Storage handles the storage of binary on a Google Cloud Storage bucket
See Binary the general interface
Webda Modda
GoogleCloudStorage
Extends
CloudBinary<T>
Type parameters
• T extends StorageParameters = StorageParameters
Constructors
new Storage(webda, name, params)
new Storage<
T>(webda,name,params?):Storage<T>
Service
Parameters
• webda: Core<CoreEvents>
The main instance of Webda
• name: string
The name of the service
• params?: DeepPartial<T>
The parameters block define in the configuration file
Returns
Storage<T>
Inherited from
CloudBinary<T>.constructor
Source
core/lib/services/service.d.ts:167
Properties
_createException
_createException:
string
Inherited from
CloudBinary._createException
Source
core/lib/services/service.d.ts:148
_initException
_initException:
any
Inherited from
CloudBinary._initException
Source
core/lib/services/service.d.ts:150
_initTime
_initTime:
number
Inherited from
CloudBinary._initTime
Source
core/lib/services/service.d.ts:149
_lowercaseMaps
_lowercaseMaps:
any
Inherited from
CloudBinary._lowercaseMaps
Source
core/lib/services/binary.d.ts:368
_name
protected_name:string
Service name
Inherited from
CloudBinary._name
Source
core/lib/services/service.d.ts:141
_webda
protected_webda:Core<CoreEvents>
Webda Core object
Inherited from
CloudBinary._webda
Source
core/lib/services/service.d.ts:137
logger
protectedlogger:Logger
Logger with class context
Inherited from
CloudBinary.logger
Source
core/lib/services/service.d.ts:154
metrics
metrics:
Object
Type declaration
delete
delete:
Counter<string>
download
download:
Counter<string>
metadataUpdate
metadataUpdate:
Counter<string>
upload
upload:
Counter<string>
Inherited from
CloudBinary.metrics
Source
core/lib/services/binary.d.ts:369
parameters
protectedparameters:T
Hold the parameters for your service
It will be bring from the webda.config.json
Inherited from
CloudBinary.parameters
Source
core/lib/services/service.d.ts:147
captureRejectionSymbol
staticreadonlycaptureRejectionSymbol: typeofcaptureRejectionSymbol
Inherited from
CloudBinary.captureRejectionSymbol
Source
gcp/node_modules/@types/node/events.d.ts:328
captureRejections
staticcaptureRejections:boolean
Sets or gets the default captureRejection value for all emitters.
Inherited from
CloudBinary.captureRejections
Source
gcp/node_modules/@types/node/events.d.ts:333
defaultMaxListeners
staticdefaultMaxListeners:number
Inherited from
CloudBinary.defaultMaxListeners
Source
gcp/node_modules/@types/node/events.d.ts:334
errorMonitor
staticreadonlyerrorMonitor: typeoferrorMonitor
This symbol shall be used to install a listener for only monitoring 'error'
events. Listeners installed using this symbol are called before the regular
'error' listeners are called.
Installing a listener using this symbol does not change the behavior once an
'error' event is emitted, therefore the process will still crash if no
regular 'error' listener is installed.
Inherited from
CloudBinary.errorMonitor
Source
gcp/node_modules/@types/node/events.d.ts:327
Methods
__clean()
__clean():
Promise<void>
Clean the service data, can only be used in test mode
Returns
Promise<void>
Inherited from
CloudBinary.__clean
Abstract
Source
core/lib/services/service.d.ts:318
_cleanUsage()
_cleanUsage(
hash,uuid,property?):Promise<void>
Parameters
• hash: string
• uuid: string
• property?: string
Returns
Promise<void>
Overrides
CloudBinary._cleanUsage
Inherit Doc
Source
gcp/src/services/storage.ts:171
_get()
_get(
info):Promise<Readable>
Parameters
• info: BinaryMap<any>
Returns
Promise<Readable>
Overrides
CloudBinary._get
Source
gcp/src/services/storage.ts:89
_getFile()
_getFile(
req):Promise<BinaryFile<any>>
Get file either from multipart post or raw
Parameters
• req: WebContext<any, any>
Returns
Promise<BinaryFile<any>>
Inherited from
CloudBinary._getFile
Source
core/lib/services/binary.d.ts:508
_getKey()
_getKey(
hash,suffix?):string
Return the S3 key
Parameters
• hash: string
• suffix?: string
Returns
string
Inherited from
CloudBinary._getKey
Source
core/lib/services/cloudbinary.d.ts:29
_initRoutes()
_initRoutes():
void
Init the Binary system routes
Making sure parameters.expose exists prior
Returns
void
Inherited from
CloudBinary._initRoutes
Source
core/lib/services/binary.d.ts:518
_verifyMapAndStore()
_verifyMapAndStore(
ctx):Store<CoreModel,StoreParameters,StoreEvents>
Based on the request parameter verify it match a known mapping
Parameters
• ctx: WebContext<any, any>
Returns
Store<CoreModel, StoreParameters, StoreEvents>
Inherited from
CloudBinary._verifyMapAndStore
Source
core/lib/services/binary.d.ts:529
addListener()
addListener(
eventName,listener):this
Alias for emitter.on(eventName, listener).
Parameters
• eventName: string | symbol
• listener: (...args) => void
Returns
this
Inherited from
CloudBinary.addListener
Since
v0.1.26
Source
gcp/node_modules/@types/node/events.d.ts:354
addRoute()
protectedaddRoute(url,methods,executer,openapi?,override?):void
Add a route dynamicaly
Parameters
• url: string
of the route can contains dynamic part like {uuid}
• methods: HttpMethodType[]
• executer: Function
Method to execute for this route
• openapi?: OpenAPIWebdaDefinition
• override?: boolean
Returns
void
Inherited from
CloudBinary.addRoute
Source
core/lib/services/service.d.ts:241
authorizeClientEvent()
authorizeClientEvent(
_event,_context):boolean
Authorize a public event subscription
Parameters
• _event: string
• _context: OperationContext<any, any>
Returns
boolean
Inherited from
CloudBinary.authorizeClientEvent
Source
core/lib/services/service.d.ts:219
cascadeDelete()
cascadeDelete(
info,uuid):Promise<void>
Parameters
• info: BinaryMap<any>
• uuid: string
Returns
Promise<void>
Inherited from
CloudBinary.cascadeDelete
Inherit Doc
Source
core/lib/services/cloudbinary.d.ts:37
checkMap()
protectedcheckMap(object,property):void
Check if a map is defined
Parameters
• object: CoreModel
• property: string
Returns
void
Inherited from
CloudBinary.checkMap
Source
core/lib/services/binary.d.ts:480
computeParameters()
computeParameters():
void
Used to compute or derivate input parameter to attribute
Returns
void
Inherited from
CloudBinary.computeParameters
Source
core/lib/services/service.d.ts:175
delete()
delete(
object,property,index):Promise<void>
Parameters
• object: BinaryModel
• property: string
• index: number
Returns
Promise<void>
Inherited from
CloudBinary.delete
Inherit Doc
Source
core/lib/services/cloudbinary.d.ts:33
deleteObject()
deleteObject(
params):Promise<void>
Delete a file inside an existing bucket
Parameters
• params: StorageObject
Returns
Promise<void>
Source
gcp/src/services/storage.ts:215
deleteSuccess()
deleteSuccess(
object,property,index?):Promise<any>
Parameters
• object: BinaryModel<Object>
• property: string
• index?: number
Returns
Promise<any>
Inherited from
CloudBinary.deleteSuccess
Source
core/lib/services/binary.d.ts:502
downloadTo()
downloadTo(
info,filename):Promise<void>
Download a binary to a file
Parameters
• info: BinaryMap<any>
The reference stored in your target object
• filename: any
Returns
Promise<void>
Inherited from
CloudBinary.downloadTo
Source
core/lib/services/binary.d.ts:449
emit()
emit<
Key>(event,data):boolean
Override to allow capturing long listeners
Type parameters
• Key extends keyof BinaryEvents
Parameters
• event: symbol | Key
• data: BinaryEvents[Key]
Returns
boolean
Inherited from
CloudBinary.emit
Source
core/lib/services/service.d.ts:288
emitSync()
emitSync<
Key>(event,data):Promise<any[]>
Emit the event with data and wait for Promise to finish if listener returned a Promise
Type parameters
• Key extends keyof BinaryEvents
Parameters
• event: Key
• data: BinaryEvents[Key]
Returns
Promise<any[]>
Inherited from
CloudBinary.emitSync
Source
core/lib/services/service.d.ts:283
eventNames()
eventNames(): (
string|symbol)[]
Returns an array listing the events for which the emitter has registered
listeners. The values in the array are strings or Symbols.
const EventEmitter = require('events');
const myEE = new EventEmitter();
myEE.on('foo', () => {});
myEE.on('bar', () => {});
const sym = Symbol('symbol');
myEE.on(sym, () => {});
console.log(myEE.eventNames());
// Prints: [ 'foo', 'bar', Symbol(symbol) ]
Returns
(string | symbol)[]
Inherited from
CloudBinary.eventNames
Since
v6.0.0
Source
gcp/node_modules/@types/node/events.d.ts:669
get()
get(
info):Promise<Readable>
Get a binary
Parameters
• info: BinaryMap<any>
The reference stored in your target object
Returns
Promise<Readable>
Inherited from
CloudBinary.get
Emits
'binaryGet'
Source
core/lib/services/binary.d.ts:442
getBucketSize()
getBucketSize(
bucket?,prefix?,regex?):Promise<Object>
Get a bucket size with a prefix
Parameters
• bucket?: string
• prefix?: string
on the bucket
• regex?: RegExp
to filter files
Returns
Promise<Object>
count
count:
numbersize
size:
number
Source
gcp/src/services/storage.ts:335
getClientEvents()
getClientEvents():
string[]
Return the events that an external system can subscribe to
Returns
string[]
Inherited from
CloudBinary.getClientEvents
Source
core/lib/services/service.d.ts:213
getContent()
getContent(
params):Promise<Readable>
Get object content in Buffer
Parameters
• params: StorageObject
Returns
Promise<Readable>
Source
gcp/src/services/storage.ts:109
getMaxListeners()
getMaxListeners():
number
Returns the current max listener value for the EventEmitter which is either
set by emitter.setMaxListeners(n) or defaults to defaultMaxListeners.
Returns
number
Inherited from
CloudBinary.getMaxListeners
Since
v1.0.0
Source
gcp/node_modules/@types/node/events.d.ts:526
getMeta()
getMeta(
store):Promise<StorageObjectMeta>
Fetch an object's metadata
Parameters
• store: StorageObject
Returns
Promise<StorageObjectMeta>
Metadata
Source
gcp/src/services/storage.ts:321
getMetric()
getMetric<
T>(type,configuration):T
Add service name label
Type parameters
• T = Counter<string> | Histogram<string> | Gauge<string>
Parameters
• type: Constructor<T, [MetricConfiguration<T>]>
• configuration: MetricConfiguration<T>
Returns
T
Inherited from
CloudBinary.getMetric
Source
core/lib/services/service.d.ts:207
getName()
getName():
string
Get service name
Returns
string
Inherited from
CloudBinary.getName
Source
core/lib/services/service.d.ts:312
getOpenApiReplacements()
getOpenApiReplacements():
any
Return variables for replacement in openapi
Returns
any
Inherited from
CloudBinary.getOpenApiReplacements
Source
core/lib/services/service.d.ts:246
getOperationId()
getOperationId(
id):string
If undefined is returned it cancel the operation registration
Parameters
• id: string
Returns
string
Inherited from
CloudBinary.getOperationId
Source
core/lib/services/service.d.ts:233
getOperationName()
protectedgetOperationName():string
Return the name of the service for OpenAPI
Returns
string
Inherited from
CloudBinary.getOperationName
Source
core/lib/services/binary.d.ts:523
getParameters()
getParameters():
T
Get the service parameters
Returns
T
Inherited from
CloudBinary.getParameters
Source
core/lib/services/service.d.ts:179
getPublicUrl()
getPublicUrl(
store):Promise<string>
Retrieve public URL of this object
Parameters
• store: StorageObject
Returns
Promise<string>
Public URL in order to download the file
Source
gcp/src/services/storage.ts:312
getRedirectUrlFromObject()
getRedirectUrlFromObject(
binaryMap,context,expires?):Promise<string>
Get a UrlFromObject
Parameters
• binaryMap: any
• context: any
• expires?: number
Returns
Promise<string>
Inherited from
CloudBinary.getRedirectUrlFromObject
Source
core/lib/services/cloudbinary.d.ts:22
getService()
getService<
K>(service):K
Return a webda service
Type parameters
• K extends Service<ServiceParameters, Events>
Parameters
• service: string
name to retrieve
Returns
K
Inherited from
CloudBinary.getService
Source
core/lib/services/service.d.ts:308
getSignedUrl()
getSignedUrl(
params):Promise<string>
Retrieve one signed URL to download the file in parameter
Parameters
• params: SignedUrlParams
Returns
Promise<string>
URL in order to download the file
Source
gcp/src/services/storage.ts:286
getSignedUrlFromMap()
getSignedUrlFromMap(
map,expires,_context):Promise<string>
Parameters
• map: BinaryMap<any>
• expires: number
• _context: OperationContext<any, any>
Returns
Promise<string>
Overrides
CloudBinary.getSignedUrlFromMap
Source
gcp/src/services/storage.ts:97
getSignedUrlHeaders()
getSignedUrlHeaders():
Object
Retrieve mandatory headers if needed by the cloud provider (ie. Azure) Returns empty object if no headers are mandatory
Returns
Object
mandatory headers
Source
gcp/src/services/storage.ts:303
getStorageBucket()
getStorageBucket(
bucket):Bucket
Return the Google Bucket directly
Parameters
• bucket: string= undefined
name of the bucket default to the one predefined
Returns
Bucket
Source
gcp/src/services/storage.ts:164
getUrl()
getUrl(
url,_methods):string
Return the full path url based on parameters
Parameters
• url: string
relative url to service
• _methods: HttpMethodType[]
in case we need filtering (like Store)
Returns
string
absolute url or undefined if need to skip the Route
Inherited from
CloudBinary.getUrl
Source
core/lib/services/service.d.ts:227
getUsageCount()
getUsageCount(
hash):Promise<number>
Parameters
• hash: string
Returns
Promise<number>
Overrides
CloudBinary.getUsageCount
Inherit Doc
Source
gcp/src/services/storage.ts:185
getWebda()
getWebda():
Core<CoreEvents>
Return WebdaCore
Returns
Core<CoreEvents>
Inherited from
CloudBinary.getWebda
Source
core/lib/services/service.d.ts:183
handleBinary()
handleBinary(
modelName,attribute):-1|0|1|2
Define if binary is managed by the store
Parameters
• modelName: string
• attribute: string
Returns
-1 | 0 | 1 | 2
-1 if not managed, 0 if managed but by default, 1 if managed and in the map, 2 if explicit with attribute and model
Inherited from
CloudBinary.handleBinary
Source
core/lib/services/binary.d.ts:398
httpChallenge()
httpChallenge(
ctx):Promise<void>
Mechanism to add a data based on challenge
Parameters
• ctx: WebContext<BinaryFile<any>, any>
Returns
Promise<void>
Inherited from
CloudBinary.httpChallenge
Source
core/lib/services/binary.d.ts:545
httpGet()
httpGet(
context):Promise<void>
Redirect to the temporary link to S3 object or return it if returnInfo=true
Parameters
• context: WebContext<any, any>