From 6e849fd5f8dd80c6e31927844e78f30179d6d69d Mon Sep 17 00:00:00 2001 From: Santhosh Ramaraj Date: Wed, 6 Nov 2024 20:18:42 -0600 Subject: [PATCH] feat: example to upload file to SystemLink --- docs/getting_started.rst | 6 ++++++ examples/file/upload_file.py | 12 ++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 examples/file/upload_file.py diff --git a/docs/getting_started.rst b/docs/getting_started.rst index 0efe9358..e4148af7 100644 --- a/docs/getting_started.rst +++ b/docs/getting_started.rst @@ -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: \ No newline at end of file diff --git a/examples/file/upload_file.py b/examples/file/upload_file.py new file mode 100644 index 00000000..735aefd2 --- /dev/null +++ b/examples/file/upload_file.py @@ -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}")