Skip to content

Commit

Permalink
feat: example to upload file to SystemLink
Browse files Browse the repository at this point in the history
  • Loading branch information
santhoshramaraj committed Nov 7, 2024
1 parent e1dc1c6 commit 6e849fd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -182,5 +182,11 @@ Examples
Get the metadata of a File using its Id and download it.

.. literalinclude:: ../examples/file/download_file.py
:language: python
:linenos:

Upload a File from disk to SystemLink

.. literalinclude:: ../examples/file/upload_file.py
:language: python
:linenos:
12 changes: 12 additions & 0 deletions examples/file/upload_file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""Example to upload a file to SystemLink."""

from nisystemlink.clients.file import FileClient

client = FileClient()

file_path = "path/to/your/file"
workspace_id = None # Upload to default workspace of the auth key

with open(file_path, "rb") as fp:
file_id = client.upload_file(file=fp, workspace=workspace_id)
print(f"Uploaded file from {file_path} to SystemLink with FileID - {file_id}")

0 comments on commit 6e849fd

Please sign in to comment.