File tree 2 files changed +25
-0
lines changed
2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -212,6 +212,10 @@ Get the metadata of a File using its Id and download it.
212
212
:language: python
213
213
:linenos:
214
214
215
+ Upload a File from disk or memory to SystemLink
216
+
217
+ .. literalinclude :: ../examples/file/upload_file.py
218
+
215
219
Feeds API
216
220
-------
217
221
Original file line number Diff line number Diff line change
1
+ """Example to upload a file to SystemLink."""
2
+
3
+ import io
4
+
5
+ from nisystemlink .clients .file import FileClient
6
+
7
+ client = FileClient ()
8
+
9
+ workspace_id = None # Upload to default workspace of the auth key
10
+
11
+ # Upload file from disk
12
+ file_path = "path/to/your/file"
13
+ with open (file_path , "rb" ) as fp :
14
+ file_id = client .upload_file (file = fp , workspace = workspace_id )
15
+ print (f"Uploaded file from { file_path } to SystemLink with FileID - { file_id } " )
16
+
17
+ # Upload file-like object from memory
18
+ test_file = io .BytesIO (b"This is an example file content." )
19
+ test_file .name = "File_From_Memory.txt" # assign a name to the file object
20
+ file_id = client .upload_file (file = test_file )
21
+ print (f"Uploaded file from memory to SystemLink with FileID - { file_id } " )
You can’t perform that action at this time.
0 commit comments