Skip to content

Commit c1e4a7e

Browse files
SK-2838: update readme for file upload
1 parent f02f982 commit c1e4a7e

1 file changed

Lines changed: 22 additions & 7 deletions

File tree

README.md

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -410,21 +410,36 @@ Refer to [Query your data](https://docs.skyflow.com/query-data/) and [Execute Qu
410410

411411
### Upload File
412412

413-
Upload files to a Skyflow vault using the `upload_file` method. Create a file upload request with the `FileUploadRequest` class, which accepts parameters such as the table name, column name, and Skyflow ID.
413+
Upload files to a Skyflow vault using the `upload_file` method. Create a file upload request with the `FileUploadRequest` class.
414+
415+
**Upload a file to an existing record:**
414416

415417
```python
416418
from skyflow.vault.data import FileUploadRequest
417419

418420
# Open the file in binary read mode
419421
with open('path/to/file.pdf', 'rb') as file_obj:
420422
upload_request = FileUploadRequest(
421-
table='documents', # Table name
422-
column_name='attachment', # Column name to store file
423-
skyflow_id='<SKYFLOW_ID>', # Skyflow ID of the record
424-
file_object=file_obj # Pass file object
423+
table='<TABLE_NAME>',
424+
column_name='<COLUMN_NAME>',
425+
skyflow_id='<SKYFLOW_ID>',
426+
file_object=file_obj
427+
)
428+
429+
response = skyflow_client.vault('<VAULT_ID>').upload_file(upload_request)
430+
print('File upload:', response)
431+
```
432+
433+
**Upload a file and create a new record (omit `skyflow_id`):**
434+
435+
```python
436+
with open('path/to/file.pdf', 'rb') as file_obj:
437+
upload_request = FileUploadRequest(
438+
table='documents',
439+
column_name='attachment',
440+
file_object=file_obj
425441
)
426-
427-
# Perform File Upload
442+
428443
response = skyflow_client.vault('<VAULT_ID>').upload_file(upload_request)
429444
print('File upload:', response)
430445
```

0 commit comments

Comments
 (0)