Class: FilestackClient
- Inherits:
-
Object
- Object
- FilestackClient
- Includes:
- MultipartUploadUtils, UploadUtils
- Defined in:
- lib/filestack/models/filestack_client.rb
Overview
The Filestack FilestackClient class acts as a hub for all Filestack actions that do not require a file handle, including uploading files (both local and external), initiating an external transformation, and other tasks
Instance Attribute Summary collapse
-
#apikey ⇒ Object
readonly
Returns the value of attribute apikey.
-
#security ⇒ Object
readonly
Returns the value of attribute security.
Instance Method Summary collapse
-
#initialize(apikey, security: nil) ⇒ FilestackClient
constructor
Initialize FilestackClient.
-
#transform_external(external_url) ⇒ Filestack::Transform
Transform an external URL.
-
#upload(filepath: nil, external_url: nil, multipart: true, options: nil, storage: 's3', intelligent: false, timeout: 60) ⇒ Object
Upload a local file or external url return [Filestack::FilestackFilelink].
Methods included from UploadUtils
#get_url, #make_call, #send_upload
Methods included from MultipartUploadUtils
#create_upload_jobs, #get_file_info, #multipart_complete, #multipart_start, #multipart_upload, #run_uploads, #upload_chunk
Constructor Details
#initialize(apikey, security: nil) ⇒ FilestackClient
Initialize FilestackClient
19 20 21 22 |
# File 'lib/filestack/models/filestack_client.rb', line 19 def initialize(apikey, security: nil) @apikey = apikey @security = security end |
Instance Attribute Details
#apikey ⇒ Object (readonly)
Returns the value of attribute apikey
12 13 14 |
# File 'lib/filestack/models/filestack_client.rb', line 12 def apikey @apikey end |
#security ⇒ Object (readonly)
Returns the value of attribute security
12 13 14 |
# File 'lib/filestack/models/filestack_client.rb', line 12 def security @security end |
Instance Method Details
#transform_external(external_url) ⇒ Filestack::Transform
Transform an external URL
55 56 57 |
# File 'lib/filestack/models/filestack_client.rb', line 55 def transform_external(external_url) Transform.new(external_url: external_url, security: @security, apikey: @apikey) end |
#upload(filepath: nil, external_url: nil, multipart: true, options: nil, storage: 's3', intelligent: false, timeout: 60) ⇒ Object
Upload a local file or external url return [Filestack::FilestackFilelink]
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/filestack/models/filestack_client.rb', line 32 def upload(filepath: nil, external_url: nil, multipart: true, options: nil, storage: 's3', intelligent: false, timeout: 60) if filepath && external_url return 'You cannot upload a URL and file at the same time' end response = if filepath && multipart multipart_upload(@apikey, filepath, @security, , timeout, intelligent: intelligent) else send_upload( @apikey, filepath: filepath, external_url: external_url, options: , security: @security, storage: storage ) end FilestackFilelink.new(response['handle'], security: @security, apikey: @apikey) end |