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:



422
423
424
# File 'lib/hubspot_sdk/resources/files/file_assets.rb', line 422

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_by_path(path, properties: nil, request_options: {}) ⇒ HubSpotSDK::Models::Files::FileStat

Retrieve a file by its path.

Parameters:

Returns:

See Also:



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

def get_by_path(path, params = {})
  parsed, options = HubSpotSDK::Files::FileAssetGetByPathParams.dump_request(params)
  query = HubSpotSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["files/2026-03/files/stat/%1$s", path],
    query: query,
    model: HubSpotSDK::Files::FileStat,
    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:



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

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:



191
192
193
194
195
196
197
198
199
200
201
# File 'lib/hubspot_sdk/resources/files/file_assets.rb', line 191

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:



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

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:



260
261
262
263
264
265
266
267
268
269
270
# File 'lib/hubspot_sdk/resources/files/file_assets.rb', line 260

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:



357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
# File 'lib/hubspot_sdk/resources/files/file_assets.rb', line 357

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:



407
408
409
410
411
412
413
414
415
416
417
# File 'lib/hubspot_sdk/resources/files/file_assets.rb', line 407

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