S3Binary
Class: S3Binary<T>
S3Binary handles the storage of binary on a S3 bucket
The structure used for now is /{hash}/data /{hash}/{targetStore}_{uuid} The challenge is stored on the metadata of the data object
It takes parameters bucket: "bucketName" accessKeyId: "" secretAccessKey: "" region: ""
See Binary the general interface
We can register on S3 Event to get info when /data is pushed
Webda Modda
Extends
CloudBinary<T>
Type parameters
• T extends S3BinaryParameters = S3BinaryParameters
Implements
Constructors
new S3Binary(webda, name, params)
new S3Binary<
T>(webda,name,params?):S3Binary<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
S3Binary<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
_s3
_s3:
S3
Source
aws/src/services/s3binary.ts:63
_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
aws/node_modules/@types/node/events.d.ts:38
captureRejections
staticcaptureRejections:boolean
Sets or gets the default captureRejection value for all emitters.
Inherited from
CloudBinary.captureRejections
Source
aws/node_modules/@types/node/events.d.ts:44
defaultMaxListeners
staticdefaultMaxListeners:number
Inherited from
CloudBinary.defaultMaxListeners
Source
aws/node_modules/@types/node/events.d.ts:45
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
aws/node_modules/@types/node/events.d.ts:37
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
_cleanHash()
_cleanHash(
hash):Promise<void>
Parameters
• hash: string
Returns
Promise<void>
Inherit Doc
Source
aws/src/services/s3binary.ts:214
_cleanUsage()
_cleanUsage(
hash,uuid,attribute?):Promise<void>
Parameters
• hash: string
• uuid: string
• attribute?: string
Returns
Promise<void>
Overrides
CloudBinary._cleanUsage
Inherit Doc
Source
aws/src/services/s3binary.ts:225
_exists()
_exists(
hash):Promise<boolean>
Parameters
• hash: string
Returns
Promise<boolean>
Inherit Doc
Source
aws/src/services/s3binary.ts:237
_get()
_get(
info):Promise<Readable>
Parameters
• info: BinaryMap<any>
Returns
Promise<Readable>
Overrides
CloudBinary._get
Source
aws/src/services/s3binary.ts:181
_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
_getS3()
_getS3(
hash):Promise<HeadObjectCommandOutput>
Get a head object
Parameters
• hash: string
Returns
Promise<HeadObjectCommandOutput>
Source
aws/src/services/s3binary.ts:254
_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(
event,listener):this
Parameters
• event: string | symbol
• listener: (...args) => void
Returns
this
Inherited from
CloudBinary.addListener
Source
aws/node_modules/@types/node/events.d.ts:57
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
Returns
void
Overrides
CloudBinary.computeParameters
Inherit Doc
Source
aws/src/services/s3binary.ts:77
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
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
(string | symbol)[]
Inherited from
CloudBinary.eventNames
Source
aws/node_modules/@types/node/events.d.ts:72
exists()
exists(
Key,Bucket):Promise<HeadObjectCommandOutput>
Check if an object exists on S3
Parameters
• Key: string
• Bucket: string= undefined
Returns
Promise<HeadObjectCommandOutput>
Source
aws/src/services/s3binary.ts:190
forEachFile()
forEachFile(
Bucket,callback,Prefix,filter):Promise<void>
Parameters
• Bucket: string
to iterate on
• callback: (Key, page) => Promise<void>
to execute with each key
• Prefix: string= ""
to use
• filter: RegExp= undefined
regexp to execute on the key
Returns
Promise<void>
Source
aws/src/services/s3binary.ts:284
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
getARNPolicy()
getARNPolicy(
_accountId):Object
Parameters
• _accountId: string
Returns
Object
Action
Action:
string[]Effect
Effect:
string="Allow"Resource
Resource:
string[]Sid
Sid:
string
Inherit Doc
Source
aws/src/services/s3binary.ts:354
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
getCloudFormation()
getCloudFormation(
deployer):Object
Parameters
• deployer: default
Returns
Object
Implementation of
CloudFormationContributor.getCloudFormation
Inherit Doc
Source
aws/src/services/s3binary.ts:386
getMaxListeners()
getMaxListeners():
number
Returns
number
Inherited from
CloudBinary.getMaxListeners
Source
aws/node_modules/@types/node/events.d.ts:64
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
getObject()
getObject(
key,bucket?):Promise<Readable>
Get an object from s3 bucket
Parameters
• key: string
to get
• bucket?: string
to retrieve from or default bucket
Returns
Promise<Readable>
Source
aws/src/services/s3binary.ts:271
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
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(
key,action,params):Promise<string>
Return a signed url to an object
Parameters
• key: string
to the object
• action: "getObject" | "putObject"= "getObject"
to perform
• params: any= {}
Returns
Promise<string>
Source
aws/src/services/s3binary.ts:150
getSignedUrlFromMap()
getSignedUrlFromMap(
binaryMap,expire,_context):Promise<string>
Parameters
• binaryMap: BinaryMap<any>
• expire: number
• _context: OperationContext<any, any>
Returns
Promise<string>
Overrides
CloudBinary.getSignedUrlFromMap
Source
aws/src/services/s3binary.ts:168
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
aws/src/services/s3binary.ts:204
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>
Returns
Promise<void>
Inherited from
CloudBinary.httpGet
Source
core/lib/services/binary.d.ts:386
httpRoute()
httpRoute(
ctx):Promise<void>
Manage the different routes
Parameters
• ctx: WebContext<any, any>
Returns
Promise<void>
Inherited from
CloudBinary.httpRoute
Source
core/lib/services/binary.d.ts:550
init()
init():
Promise<S3Binary<T>>
Will be called after all the Services are created
Returns
Promise<S3Binary<T>>
Inherited from
CloudBinary.init
Abstract
Source
core/lib/services/service.d.ts:274
initMap()
initMap(
map):void
Init the declared maps, adding reverse maps
Parameters
• map: any
Returns
void
Inherited from
CloudBinary.initMap
Source
core/lib/services/binary.d.ts:460
initMetrics()
initMetrics():
void
Returns
void
Inherited from
CloudBinary.initMetrics
Source
core/lib/services/binary.d.ts:378
initOperations()
initOperations():
void
Init the operations
Returns
void
Inherited from
CloudBinary.initOperations
Source
core/lib/services/service.d.ts:254
initRoutes()
initRoutes():
void
Returns
void
Inherited from
CloudBinary.initRoutes
Source
core/lib/services/binary.d.ts:512
listenerCount()
listenerCount(
event):number
Parameters
• event: string | symbol
Returns
number
Inherited from
CloudBinary.listenerCount
Source
aws/node_modules/@types/node/events.d.ts:68
listeners()
listeners(
event):Function[]
Parameters
• event: string | symbol
Returns
Function[]
Inherited from
CloudBinary.listeners
Source
aws/node_modules/@types/node/events.d.ts:65
loadParameters()
loadParameters(
params):S3BinaryParameters
Load the parameters
Parameters
• params: any
Returns
Overrides
CloudBinary.loadParameters
Source
aws/src/services/s3binary.ts:70
log()
log(
level, ...args):void
Parameters
• level: WorkerLogLevel
to log
• ...args: any[]
Returns
void
Inherited from
CloudBinary.log
Source
core/lib/services/service.d.ts:328
newModel()
newModel(
obj):BinaryMap<any>
Based on the raw Map init a BinaryMap
Parameters
• obj: any
Returns
BinaryMap<any>
Inherited from
CloudBinary.newModel
Source
core/lib/services/binary.d.ts:466
off()
off(
event,listener):this
Parameters
• event: string | symbol
• listener: (...args) => void
Returns
this
Inherited from
CloudBinary.off
Source
aws/node_modules/@types/node/events.d.ts:61
on()
on<
Key>(event,listener):this
Type the listener part
Type parameters
• Key extends keyof BinaryEvents
Parameters
• event: symbol | Key
• listener: (evt) => void
Returns
this
Inherited from
CloudBinary.on
Source
core/lib/services/service.d.ts:296
onAsync()
onAsync<
Key>(event,listener,queue?):void
Listen to an event as on(...) would do except that it will be asynchronous
Type parameters
• Key extends keyof BinaryEvents
Parameters
• event: Key
• listener: (evt) => void
• queue?: string
Name of queue to use, can be undefined, queue name are used to define differents priorities
Returns
void
Inherited from
CloudBinary.onAsync
Source
core/lib/services/service.d.ts:303
once()
once(
event,listener):this
Parameters
• event: string | symbol
• listener: (...args) => void
Returns
this
Inherited from
CloudBinary.once
Source
aws/node_modules/@types/node/events.d.ts:59
prependListener()
prependListener(
event,listener):this
Parameters
• event: string | symbol
• listener: (...args) => void
Returns
this
Inherited from
CloudBinary.prependListener
Source
aws/node_modules/@types/node/events.d.ts:70
prependOnceListener()
prependOnceListener(
event,listener):this
Parameters
• event: string | symbol
• listener: (...args) => void
Returns
this
Inherited from
CloudBinary.prependOnceListener
Source
aws/node_modules/@types/node/events.d.ts:71
putMarker()
putMarker(
hash,suffix,storeName):Promise<PutObjectCommandOutput>
Parameters
• hash: string
• suffix: string
• storeName: string
Returns
Promise<PutObjectCommandOutput>
Inherit Doc
Source
aws/src/services/s3binary.ts:133
putObject()
putObject(
key,body,metadatas,bucket):Promise<void>
Add an object to S3 bucket
Parameters
• key: string
to add to
• body: string | Blob | Buffer | ReadableStream<any>
content of the object
• metadatas: Object= {}
to put along the object
• bucket: string= undefined
to use
Returns
Promise<void>
Source
aws/src/services/s3binary.ts:316
putRedirectUrl()
putRedirectUrl(
ctx):Promise<Object>
Parameters
• ctx: WebContext<any, any>
Returns
Promise<Object>
headers
headers:
ObjectIndex signature
[
key:string]:stringmethod
method:
stringurl
url:
string
Overrides
CloudBinary.putRedirectUrl
Inherit Doc
Source
aws/src/services/s3binary.ts:84
rawListeners()
rawListeners(
event):Function[]
Parameters
• event: string | symbol
Returns
Function[]
Inherited from
CloudBinary.rawListeners
Source
aws/node_modules/@types/node/events.d.ts:66
reinit()
reinit(
config):Promise<S3Binary<T>>
Parameters
• config: DeepPartial<T>
new parameters for the service
Returns
Promise<S3Binary<T>>
Inherited from
CloudBinary.reinit
Source
core/lib/services/service.d.ts:279
removeAllListeners()
removeAllListeners(
event?):this
Parameters
• event?: string | symbol
Returns
this
Inherited from
CloudBinary.removeAllListeners
Source
aws/node_modules/@types/node/events.d.ts:62
removeListener()
removeListener(
event,listener):this
Parameters
• event: string | symbol
• listener: (...args) => void
Returns
this
Inherited from
CloudBinary.removeListener
Source
aws/node_modules/@types/node/events.d.ts:60
resolve()
resolve():
this
Returns
this
Inherited from
CloudBinary.resolve
Source
core/lib/services/binary.d.ts:453
setMaxListeners()
setMaxListeners(
n):this
Parameters
• n: number
Returns
this
Inherited from
CloudBinary.setMaxListeners
Source
aws/node_modules/@types/node/events.d.ts:63
stop()
stop():
Promise<void>
Shutdown the current service if action need to be taken
Returns
Promise<void>
Inherited from
CloudBinary.stop
Source
core/lib/services/service.d.ts:187
store()
store(
object,property,file):Promise<void>
Parameters
• object: CoreModel
• property: string
• file: BinaryFile<any>
Returns
Promise<void>
Overrides
CloudBinary.store
Inherit Doc
Source
aws/src/services/s3binary.ts:329
toJSON()
toJSON():
string
Prevent service to be serialized
Returns
string
Inherited from
CloudBinary.toJSON
Source
core/lib/services/service.d.ts:267
toPublicJSON()
toPublicJSON(
object):string
Convert an object to JSON using the Webda json filter
Service
Parameters
• object: unknown
The object to export
Returns
string
The export of the strip object ( removed all attribute with _ )
Inherited from
CloudBinary.toPublicJSON
Source
core/lib/services/service.d.ts:262
toString()
toString():
string
Return service representation
Returns
string
Inherited from
CloudBinary.toString
Source
core/lib/services/service.d.ts:191
uploadSuccess()
uploadSuccess(
object,property,fileInfo):Promise<void>
Ensure events are sent correctly after an upload and update the BinaryFileInfo in targetted object
Parameters
• object: BinaryModel<Object>
• property: string
• fileInfo: BinaryFileInfo | Object
Returns
Promise<void>
Inherited from
CloudBinary.uploadSuccess
Source
core/lib/services/binary.d.ts:484
listenerCount()
staticlistenerCount(emitter,event):number
Parameters
• emitter: EventEmitter
• event: string | symbol
Returns
number
Inherited from
CloudBinary.listenerCount
Deprecated
since v4.0.0
Source
aws/node_modules/@types/node/events.d.ts:26
on()
staticon(emitter,event):AsyncIterableIterator<any,any,any>
Parameters
• emitter: EventEmitter
• event: string
Returns
AsyncIterableIterator<any, any, any>
Inherited from
CloudBinary.on
Source
aws/node_modules/@types/node/events.d.ts:23
once()
once(emitter, event)
staticonce(emitter,event):Promise<any[]>
Parameters
• emitter: NodeEventTarget
• event: string | symbol
Returns
Promise<any[]>
Inherited from
CloudBinary.once
Source
aws/node_modules/@types/node/events.d.ts:21
once(emitter, event)
staticonce(emitter,event):Promise<any[]>
Parameters
• emitter: DOMEventTarget
• event: string
Returns
Promise<any[]>
Inherited from
CloudBinary.once
Source
aws/node_modules/@types/node/events.d.ts:22
streamToBuffer()
staticstreamToBuffer(stream):Promise<Buffer>
Read a stream to a buffer
Parameters
• stream: Readable
Returns
Promise<Buffer>
Inherited from
CloudBinary.streamToBuffer
Source
core/lib/services/binary.d.ts:473