Options
All
  • Public
  • Public/Protected
  • All
Menu

Class S3FileJob

Hierarchy

Index

Constructors

constructor

Properties

Private _bucket

_bucket: string

Private _eTag

_eTag: string

Protected _file

_file: File

Protected _id

_id: string

Private _key

_key: string

Protected _lifeCycle

_lifeCycle: LifeEvent[]

Protected _locallyAvailable

_locallyAvailable: boolean

Protected _name

_name: string

Protected _nest

_nest: Nest

Protected _properties

_properties: any

Protected _tunnel

_tunnel: Tunnel

Protected _type

_type: string

Protected e

Accessors

basename

  • get basename(): string

bucket

  • get bucket(): string
  • set bucket(bucket: string): void

contentType

  • get contentType(): string

dirname

  • get dirname(): string

eTag

  • get eTag(): string
  • set eTag(eTag: string): void

extension

  • get extension(): string

file

files

  • get files(): any

id

  • get id(): string

isLocallyAvailable

  • get isLocallyAvailable(): boolean

key

  • get key(): string
  • set key(key: string): void

lifeCycle

locallyAvailable

  • set locallyAvailable(available: boolean): void

name

  • get name(): string
  • set name(filename: string): void

nameProper

  • get nameProper(): any

nest

  • get nest(): Nest
  • set nest(nest: Nest): void

path

  • get path(): string
  • set path(path: string): void

properties

  • get properties(): any

propertyValues

  • set propertyValues(properties: Object): void

size

  • get size(): any

sizeBytes

  • get sizeBytes(): number

tunnel

type

  • get type(): string

Methods

Protected createLifeEvent

  • createLifeEvent(verb: string, start: string, finish: string): void

email

  • Sends an email.

    Parameters

    • emailOptions: EmailOptions

      Email options

      Sending pug template email example

      // my_tunnel.js
      tunnel.run(function (job, nest) {
           job.email({
               subject: "Test email from pug template",
               to: "john.smith@example.com",
               template: __dirname + "./template_files/my_email.pug"
           });
      });
      
      // template_files/my_email.pug
      h1="Example email!"
      p="Got job ID " + job.getId()
      

      Sending plain-text email

      tunnel.run(function (job, nest) {
           job.email({
               subject: "Test email with hard-coded plain-text",
               to: "john.smith@example.com",
               text: "My email body!"
           });
      });
      

      Sending html email

      tunnel.run(function (job, nest) {
           job.email({
               subject: "Test email with hard-coded html",
               to: "john.smith@example.com",
               html: "<h1>My email body!</h1>"
           });
      });
      

    Returns void

fail

  • fail(reason: string): void
  • Function to call to fail a job while in a tunnel.

    Parameters

    • reason: string

    Returns void

getFile

  • getFile(index: any): any

getJSON

  • getJSON(): any

getProperty

getPropertyType

  • getPropertyType(key: string): any
  • Get the type of a property.

    Example

    job.setPropertyValue("My Job Number", 123456);
    
    console.log(job.getPropertyType("My Job Number"));
    // "number"
    

    Parameters

    • key: string

    Returns any

getPropertyValue

  • getPropertyValue(key: string): any

isFile

  • isFile(): boolean

isFolder

  • isFolder(): boolean

log

  • log(level: number, message: string): void
  • Add a message to the log with this job as the actor.

    Parameters

    • level: number

      0 = debug, 1 = info, 2, = warning, 3 = error

    • message: string

      Log message

    Returns void

move

  • move(destinationNest: Nest, callback: function): void
  • Moves a file to a nest. This is an asynchronous method which provides a callback on completion.

    Parameters

    • destinationNest: Nest

      The nest object the job will be sent to.

    • callback: function

      The callback provides the updated instance of the job. Depending on the nest it was sent to, it may have been cast to a new job type. This is helpful in case you need the remote path to the job once it has been uploaded to S3, for example.

      Example

      tunnel.run((job, nest) => {
           console.log("Found job " + job.name);
           job.move(my_s3_bucket, (s3_job) => {
               // Uploaded
               console.log("Uploaded to " + s3_job.path); // https://mybucket.s3.amazonaws.com/myfile.pdf
           });
      });
      
        • (job: Job): void
        • Parameters

          Returns void

    Returns void

pack

  • pack(callback: function): void
  • Packs the job instance and file together in a zip. Returns a PackJob in the parameter of the callback.

    Parameters

    • callback: function

      Example

      job.pack(function(packJob){
           packJob.move(packed_folder_nest);
      });
      

    Returns void

remove

  • remove(): boolean

rename

  • rename(newName: string): void

setPropertyValue

  • setPropertyValue(key: string, value: any): void
  • Attach job specific data to the job instance.

    Example

    job.setPropertyValue("My Job Number", 123456);
    
    console.log(job.getPropertyValue("My Job Number"));
    // 123456
    

    Parameters

    • key: string
    • value: any

    Returns void

toString

  • toString(): string

transfer

  • transfer(tunnel: Tunnel): void

unpack

  • unpack(callback: function): void
  • Unpacks a packed job. Returns a the original unpacked job in the parameter of the callback.

    Parameters

    • callback: function

      Example

      packedJob.unpack(function(unpackedJob){
          console.log("Unpacked", unpackedJob.name);
          unpackedJob.move(unpacked_folder);
          packedJob.remove();
      });
      
        • (job: Job): void
        • Parameters

          Returns void

    Returns void

Generated using TypeDoc