Class: HubSpotSDK::Resources::Files::FileAssets

Inherits:
Object
  • Object
show all
Defined in:
lib/hubspot_sdk/resources/files/file_assets.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ FileAssets

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 FileAssets.

Parameters:



399
400
401
# File 'lib/hubspot_sdk/resources/files/file_assets.rb', line 399

def initialize(client:)
  @client = client
end

Instance Method Details

#create(name:, parent_folder_id: nil, parent_path: nil, request_options: {}) ⇒ HubSpotSDK::Models::Files::Folder

Some parameter documentations has been truncated, see Models::Files::FileAssetCreateParams for more details.

Creates a folder.

Parameters:

  • name (String)

    Desired name for the folder.

  • parent_folder_id (String)

    FolderId of the parent of the created folder. If not specified, the folder will

  • parent_path (String)

    Path of the parent of the created folder. If not specified the folder will be cr

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

Returns:

See Also:



25
26
27
28
29
30
31
32
33
34
# File 'lib/hubspot_sdk/resources/files/file_assets.rb', line 25

def create(params)
  parsed, options = HubSpotSDK::Files::FileAssetCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "files/2026-03/folders",
    body: parsed,
    model: HubSpotSDK::Files::Folder,
    options: options
  )
end

#delete(file_id, request_options: {}) ⇒ nil

Delete a file by ID

Parameters:

Returns:

  • (nil)

See Also:



85
86
87
88
89
90
91
92
# File 'lib/hubspot_sdk/resources/files/file_assets.rb', line 85

def delete(file_id, params = {})
  @client.request(
    method: :delete,
    path: ["files/2026-03/files/%1$s", file_id],
    model: NilClass,
    options: params[:request_options]
  )
end

#gdpr_delete(file_id, request_options: {}) ⇒ nil

Delete a file in accordance with GDPR regulations.

Parameters:

Returns:

  • (nil)

See Also:



104
105
106
107
108
109
110
111
# File 'lib/hubspot_sdk/resources/files/file_assets.rb', line 104

def gdpr_delete(file_id, params = {})
  @client.request(
    method: :delete,
    path: ["files/2026-03/files/%1$s/gdpr-delete", file_id],
    model: NilClass,
    options: params[:request_options]
  )
end

#get(file_id, properties: nil, request_options: {}) ⇒ HubSpotSDK::Models::Files::File

Retrieve a file by its ID.

Parameters:

Returns:

See Also:



124
125
126
127
128
129
130
131
132
133
134
# File 'lib/hubspot_sdk/resources/files/file_assets.rb', line 124

def get(file_id, params = {})
  parsed, options = HubSpotSDK::Files::FileAssetGetParams.dump_request(params)
  query = HubSpotSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["files/2026-03/files/%1$s", file_id],
    query: query,
    model: HubSpotSDK::Files::File,
    options: options
  )
end

#get_import_task_status(task_id, request_options: {}) ⇒ HubSpotSDK::Models::Files::FileActionResponse

Check the status of requested import.

Parameters:

Returns:

See Also:



146
147
148
149
150
151
152
153
# File 'lib/hubspot_sdk/resources/files/file_assets.rb', line 146

def get_import_task_status(task_id, params = {})
  @client.request(
    method: :get,
    path: ["files/2026-03/files/import-from-url/async/tasks/%1$s/status", task_id],
    model: HubSpotSDK::Files::FileActionResponse,
    options: params[:request_options]
  )
end

#get_signed_url(file_id, expiration_seconds: nil, size: nil, upscale: nil, request_options: {}) ⇒ HubSpotSDK::Models::Files::SignedURL

Generates signed URL that allows temporary access to a private file.

Parameters:

Returns:

See Also:



168
169
170
171
172
173
174
175
176
177
178
# File 'lib/hubspot_sdk/resources/files/file_assets.rb', line 168

def get_signed_url(file_id, params = {})
  parsed, options = HubSpotSDK::Files::FileAssetGetSignedURLParams.dump_request(params)
  query = HubSpotSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["files/2026-03/files/%1$s/signed-url", file_id],
    query: query.transform_keys(expiration_seconds: "expirationSeconds"),
    model: HubSpotSDK::Files::SignedURL,
    options: options
  )
end

#import_from_url_async(access:, duplicate_validation_scope:, duplicate_validation_strategy:, overwrite:, expires_at: nil, folder_id: nil, folder_path: nil, name: nil, ttl: nil, url: nil, request_options: {}) ⇒ HubSpotSDK::Models::Files::ImportFromURLTaskLocator

Some parameter documentations has been truncated, see Models::Files::FileAssetImportFromURLAsyncParams for more details.

Asynchronously imports the file at the given URL into the file manager.

Parameters:

  • access (Symbol, HubSpotSDK::Models::Files::ImportFromURLInput::Access)

    PUBLIC_INDEXABLE: File is publicly accessible by anyone who has the URL. Search

  • duplicate_validation_scope (Symbol, HubSpotSDK::Models::Files::ImportFromURLInput::DuplicateValidationScope)

    ENTIRE_PORTAL: Look for a duplicate file in the entire account. EXACT_FOLDER: Lo

  • duplicate_validation_strategy (Symbol, HubSpotSDK::Models::Files::ImportFromURLInput::DuplicateValidationStrategy)

    NONE: Do not run any duplicate validation. REJECT: Reject the upload if a duplic

  • overwrite (Boolean)

    If true, will overwrite existing file if one with the same name and extension ex

  • expires_at (Time)

    Specifies the date and time when the file will expire.

  • folder_id (String)

    One of folderId or folderPath is required. Destination folderId for the uploaded

  • folder_path (String)

    One of folderPath or folderId is required. Destination folder path for the uploa

  • name (String)

    Name to give the resulting file in the file manager.

  • ttl (String)

    Time to live. If specified the file will be deleted after the given time frame.

  • url (String)

    URL to download the new file from.

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

Returns:

See Also:



212
213
214
215
216
217
218
219
220
221
# File 'lib/hubspot_sdk/resources/files/file_assets.rb', line 212

def import_from_url_async(params)
  parsed, options = HubSpotSDK::Files::FileAssetImportFromURLAsyncParams.dump_request(params)
  @client.request(
    method: :post,
    path: "files/2026-03/files/import-from-url/async",
    body: parsed,
    model: HubSpotSDK::Files::ImportFromURLTaskLocator,
    options: options
  )
end

#replace(file_id, charset_hunch: nil, file: nil, options: nil, request_options: {}) ⇒ HubSpotSDK::Models::Files::File

Replace existing file data with new file data. Can be used to change image content without having to upload a new file and update all references.

Parameters:

Returns:

See Also:



237
238
239
240
241
242
243
244
245
246
247
# File 'lib/hubspot_sdk/resources/files/file_assets.rb', line 237

def replace(file_id, params = {})
  parsed, options = HubSpotSDK::Files::FileAssetReplaceParams.dump_request(params)
  @client.request(
    method: :put,
    path: ["files/2026-03/files/%1$s", file_id],
    headers: {"content-type" => "multipart/form-data"},
    body: parsed,
    model: HubSpotSDK::Files::File,
    options: options
  )
end

#search(after: nil, allows_anonymous_access: nil, before: nil, created_at: nil, created_at_gte: nil, created_at_lte: nil, encoding: nil, expires_at: nil, expires_at_gte: nil, expires_at_lte: nil, extension: nil, file_md5: nil, height: nil, height_gte: nil, height_lte: nil, id_gte: nil, id_lte: nil, ids: nil, is_usable_in_content: nil, limit: nil, name: nil, parent_folder_ids: nil, path: nil, properties: nil, size: nil, size_gte: nil, size_lte: nil, sort: nil, type: nil, updated_at: nil, updated_at_gte: nil, updated_at_lte: nil, url: nil, width: nil, width_gte: nil, width_lte: nil, request_options: {}) ⇒ HubSpotSDK::Internal::Page<HubSpotSDK::Models::Files::File>

Some parameter documentations has been truncated, see Models::Files::FileAssetSearchParams for more details.

Search through files in the file manager. Does not display hidden or archived files.

Parameters:

  • after (String)

    The paging cursor token of the last successfully read resource will be returned

  • allows_anonymous_access (Boolean)
  • before (String)
  • created_at (Time)
  • created_at_gte (Time)
  • created_at_lte (Time)
  • encoding (String)
  • expires_at (Time)
  • expires_at_gte (Time)
  • expires_at_lte (Time)
  • extension (String)
  • file_md5 (String)
  • height (Integer)
  • height_gte (Integer)
  • height_lte (Integer)
  • id_gte (Integer)
  • id_lte (Integer)
  • ids (Array<Integer>)
  • is_usable_in_content (Boolean)
  • limit (Integer)

    The maximum number of results to display per page.

  • name (String)
  • parent_folder_ids (Array<Integer>)
  • path (String)
  • properties (Array<String>)
  • size (Integer)
  • size_gte (Integer)
  • size_lte (Integer)
  • sort (Array<String>)
  • type (String)
  • updated_at (Time)
  • updated_at_gte (Time)
  • updated_at_lte (Time)
  • url (String)
  • width (Integer)
  • width_gte (Integer)
  • width_lte (Integer)
  • request_options (HubSpotSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
# File 'lib/hubspot_sdk/resources/files/file_assets.rb', line 334

def search(params = {})
  parsed, options = HubSpotSDK::Files::FileAssetSearchParams.dump_request(params)
  query = HubSpotSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "files/2026-03/files/search",
    query: query.transform_keys(
      allows_anonymous_access: "allowsAnonymousAccess",
      created_at: "createdAt",
      created_at_gte: "createdAtGte",
      created_at_lte: "createdAtLte",
      expires_at: "expiresAt",
      expires_at_gte: "expiresAtGte",
      expires_at_lte: "expiresAtLte",
      file_md5: "fileMd5",
      height_gte: "heightGte",
      height_lte: "heightLte",
      id_gte: "idGte",
      id_lte: "idLte",
      is_usable_in_content: "isUsableInContent",
      parent_folder_ids: "parentFolderIds",
      size_gte: "sizeGte",
      size_lte: "sizeLte",
      updated_at: "updatedAt",
      updated_at_gte: "updatedAtGte",
      updated_at_lte: "updatedAtLte",
      width_gte: "widthGte",
      width_lte: "widthLte"
    ),
    page: HubSpotSDK::Internal::Page,
    model: HubSpotSDK::Files::File,
    options: options
  )
end

#update(file_id, clear_expires:, access: nil, expires_at: nil, is_usable_in_content: nil, name: nil, parent_folder_id: nil, parent_folder_path: nil, request_options: {}) ⇒ HubSpotSDK::Models::Files::File

Some parameter documentations has been truncated, see Models::Files::FileAssetUpdateParams for more details.

Update properties of file by ID.

Parameters:

  • file_id (String)
  • clear_expires (Boolean)
  • access (Symbol, HubSpotSDK::Models::Files::FileUpdateInput::Access)

    NONE: Do not run any duplicate validation. REJECT: Reject the upload if a duplic

  • expires_at (Time)
  • is_usable_in_content (Boolean)

    Mark whether the file should be used in new content or not.

  • name (String)

    New name for the file.

  • parent_folder_id (String)

    FolderId where the file should be moved to. folderId and folderPath parameters c

  • parent_folder_path (String)

    Folder path where the file should be moved to. folderId and folderPath parameter

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

Returns:

See Also:



64
65
66
67
68
69
70
71
72
73
# File 'lib/hubspot_sdk/resources/files/file_assets.rb', line 64

def update(file_id, params)
  parsed, options = HubSpotSDK::Files::FileAssetUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["files/2026-03/files/%1$s", file_id],
    body: parsed,
    model: HubSpotSDK::Files::File,
    options: options
  )
end

#upload(charset_hunch: nil, file: nil, file_name: nil, folder_id: nil, folder_path: nil, options: nil, request_options: {}) ⇒ HubSpotSDK::Models::Files::File

Upload a single file with content specified in request body.

Parameters:

  • charset_hunch (String)
  • file (Pathname, StringIO, IO, String, HubSpotSDK::FilePart)
  • file_name (String)
  • folder_id (String)
  • folder_path (String)
  • options (String)
  • request_options (HubSpotSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



384
385
386
387
388
389
390
391
392
393
394
# File 'lib/hubspot_sdk/resources/files/file_assets.rb', line 384

def upload(params = {})
  parsed, options = HubSpotSDK::Files::FileAssetUploadParams.dump_request(params)
  @client.request(
    method: :post,
    path: "files/2026-03/files",
    headers: {"content-type" => "multipart/form-data"},
    body: parsed,
    model: HubSpotSDK::Files::File,
    options: options
  )
end