-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: example to upload file object from memory
- Loading branch information
1 parent
6e849fd
commit 4a47a40
Showing
1 changed file
with
21 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,21 @@ | ||
"""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}") | ||
"""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}") |