Class: FilestackFilelink

Inherits:
Object
  • Object
show all
Includes:
FilestackCommon, UploadUtils
Defined in:
lib/filestack/models/filelink.rb

Overview

This class represents a file stored on your Filestack storage. Once initialized, you may perform transformations, conversions, get metadata, update, or delete it.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from UploadUtils

#get_url, #make_call, #send_upload

Methods included from FilestackCommon

#send_delete, #send_download, #send_get_content, #send_metadata, #send_overwrite, #send_tags

Constructor Details

#initialize(handle, apikey: nil, security: nil) ⇒ FilestackFilelink

Initialize FilestackFilelink

Parameters:

  • file_handle (String)

    The FilestackFilelink handle

  • apikey (String) (defaults to: nil)

    Your Filestack API Key (optional)

  • security (FilestackSecurity) (defaults to: nil)

    Filestack security object, if security is enabled.



21
22
23
24
25
# File 'lib/filestack/models/filelink.rb', line 21

def initialize(handle, apikey: nil, security: nil)
  @handle = handle
  @apikey = apikey
  @security = security
end

Instance Attribute Details

#apikeyObject (readonly)

Returns the value of attribute apikey.



13
14
15
# File 'lib/filestack/models/filelink.rb', line 13

def apikey
  @apikey
end

#handleObject (readonly)

Returns the value of attribute handle.



13
14
15
# File 'lib/filestack/models/filelink.rb', line 13

def handle
  @handle
end

#securityObject (readonly)

Returns the value of attribute security.



13
14
15
# File 'lib/filestack/models/filelink.rb', line 13

def security
  @security
end

Instance Method Details

#deleteTyphoeus::Response

Delete filelink

Returns:

  • (Typhoeus::Response)


46
47
48
# File 'lib/filestack/models/filelink.rb', line 46

def delete
  send_delete(handle, apikey, security)
end

#download(filepath) ⇒ Typhoeus::Response

Download FilestackFilelink

Parameters:

  • filepath (String)

    The local destination of the downloaded filelink

Returns:

  • (Typhoeus::Response)


39
40
41
# File 'lib/filestack/models/filelink.rb', line 39

def download(filepath)
  send_download(url, filepath)
end

#get_contentBytes

Get content of filelink

Returns:

  • (Bytes)


30
31
32
# File 'lib/filestack/models/filelink.rb', line 30

def get_content
  send_get_content(url)
end

#metadata(params = {}) ⇒ Hash

Return metadata for file handle

Returns:



77
78
79
# File 'lib/filestack/models/filelink.rb', line 77

def (params = {})
  (@handle, @security, params)
end

#overwrite(filepath) ⇒ Typhoeus::Response

Ovewrite filelink by uploading local file

Parameters:

  • filepath (String)

    filepath of file to upload

Returns:

  • (Typhoeus::Response)


55
56
57
# File 'lib/filestack/models/filelink.rb', line 55

def overwrite(filepath)
  send_overwrite(filepath, handle, apikey, security)
end

#sfwBool

Return true (SFW) or false (NSFW)

Returns:

  • (Bool)


84
85
86
# File 'lib/filestack/models/filelink.rb', line 84

def sfw
  send_tags('sfw', @handle, @security)
end

#tagsHash

Return auto and user tags for the filelink

Returns:



70
71
72
# File 'lib/filestack/models/filelink.rb', line 70

def tags
  send_tags('tags', @handle, @security)
end

#transformFilestack::Transform

Turn the filelink into a transform object to perform transform operations

Returns:

  • (Filestack::Transform)


63
64
65
# File 'lib/filestack/models/filelink.rb', line 63

def transform
  Transform.new(handle: @handle, apikey: @apikey, security: @security)
end

#urlString

Get the URL of the FilestackFilelink

Returns:

  • (String)


91
92
93
94
95
# File 'lib/filestack/models/filelink.rb', line 91

def url
  UploadUtils.get_url(
    FilestackConfig::CDN_URL, handle: handle, security: security
  )
end