Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions docs/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ Get the metadata of a File using its Id and download it.
:language: python
:linenos:

Upload a File from disk or memory to SystemLink

.. literalinclude:: ../examples/file/upload_file.py

Feeds API
-------

Expand Down
21 changes: 21 additions & 0 deletions examples/file/upload_file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""Example to upload a file to SystemLink."""

import io

from nisystemlink.clients.file import FileClient

client = FileClient()

workspace_id = None # Upload to default workspace of the auth key

# Upload file from disk
file_path = "path/to/your/file"
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}")

# Upload file-like object from memory
test_file = io.BytesIO(b"This is an example file content.")
test_file.name = "File_From_Memory.txt" # assign a name to the file object
file_id = client.upload_file(file=test_file)
print(f"Uploaded file from memory to SystemLink with FileID - {file_id}")