Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: example to upload file to SystemLink #81

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}")
Loading