Skip to content

Working example for file upload #260

Open
@anka

Description

@anka

Please provide a working example for the file upload using hubspot.files.files.api.files_api.FilesApi.

Using it like that

file_options = {
    "access": "PUBLIC_NOT_INDEXABLE"
}
response = FilesApi().upload(
    file_name=file_name,
    file=open('sample.txt', 'rb'),
    folder_path="/upload-folder",
    options=json.dumps(file_options),
)

results

Traceback (most recent call last):
  File "/my-project/development.py", line 25, in <module>
    r = Hubspot.upload_file(file_name="test.txt", content=f.read())
  File "/my-project/faabric_lib/hs.py", line 1577, in upload_file
    response = FilesApi().upload(
  File "/my-python/lib/python3.10/site-packages/hubspot/files/files/api/files_api.py", line 1418, in upload
    return self.upload_with_http_info(**kwargs)  # noqa: E501
  File "/my-python/lib/python3.10/site-packages/hubspot/files/files/api/files_api.py", line 1516, in upload_with_http_info
    return self.api_client.call_api(
  File "/my-python/lib/python3.10/site-packages/hubspot/files/files/api_client.py", line 378, in call_api
    return self.__call_api(
  File "/my-python/lib/python3.10/site-packages/hubspot/files/files/api_client.py", line 167, in __call_api
    post_params.extend(self.files_parameters(files))
  File "/my-python/lib/python3.10/site-packages/hubspot/files/files/api_client.py", line 481, in files_parameters
    with open(n, "rb") as f:
OSError: [Errno 63] File name too long: b'{\n  "version": "2.0",\n  ..... }\n}'

I am using hubspot-api-client==8.1.0.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions