Class: Autorender::Resources::Uploads

Inherits:
Object
  • Object
show all
Defined in:
lib/autorender/resources/uploads.rb

Overview

Upload endpoints (API key required)

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Uploads

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Uploads.

Parameters:



85
86
87
# File 'lib/autorender/resources/uploads.rb', line 85

def initialize(client:)
  @client = client
end

Instance Method Details

#create(file:, file_name:, custom_id: nil, folder: nil, metadata: nil, random_prefix: nil, tags: nil, transform: nil, webhook_url: nil, request_options: {}) ⇒ Autorender::Models::UploadCreateResponse

Upload a file from your backend server using multipart/form-data.

Parameters:

  • file (Pathname, StringIO, IO, String, Autorender::FilePart)

    File to upload.

  • file_name (String)

    File name (e.g. product.jpg)

  • custom_id (String)

    Custom identifier

  • folder (String)

    Optional folder path

  • metadata (String)

    JSON string of metadata

  • random_prefix (String)

    true/false to append random suffix

  • tags (String)

    Comma-separated tags

  • transform (String)

    Transform string (w_300,h_300,c_crop,…)

  • webhook_url (String)

    URL to notify on success

  • request_options (Autorender::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/autorender/resources/uploads.rb', line 34

def create(params)
  parsed, options = Autorender::UploadCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "api/v1/uploads",
    headers: {"content-type" => "multipart/form-data"},
    body: parsed,
    model: Autorender::Models::UploadCreateResponse,
    options: options
  )
end

#create_from_url(remote_url:, custom_id: nil, file_name: nil, folder: nil, metadata: nil, random_prefix: nil, tags: nil, webhook_url: nil, request_options: {}) ⇒ Autorender::Models::UploadCreateFromURLResponse

Download a file from a remote URL and store it in AutoRender.

Parameters:

  • remote_url (String)

    HTTP/HTTPS URL to fetch

  • custom_id (String)
  • file_name (String)

    Override file name

  • folder (String)

    Destination folder path

  • metadata (String)

    JSON string of metadata object

  • random_prefix (String)

    true/false to append random suffix

  • tags (String)

    Comma-separated tags

  • webhook_url (String)
  • request_options (Autorender::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



71
72
73
74
75
76
77
78
79
80
# File 'lib/autorender/resources/uploads.rb', line 71

def create_from_url(params)
  parsed, options = Autorender::UploadCreateFromURLParams.dump_request(params)
  @client.request(
    method: :post,
    path: "api/v1/uploads/remote",
    body: parsed,
    model: Autorender::Models::UploadCreateFromURLResponse,
    options: options
  )
end