Skip to content

Commit 9ce1865

Browse files
committed
Add support for external URLs in File model and update related tests
1 parent d6fd341 commit 9ce1865

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

synapseclient/models/file.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ async def store_async(
813813
814814
File with an external URL and a parent folder with the ID `syn456`:
815815
816-
file_instance = await File(name="my_file.txt", external_url="s3://bucket/key", parent_id="syn456", synapse_store=False).store_async()
816+
file_instance = await File(name="my_file.txt", external_url="https://example.com/link/to/thing", parent_id="syn456", synapse_store=False).store_async()
817817
818818
File with a parent and existing file handle (This allows multiple entities to reference the underlying file):
819819
@@ -1337,7 +1337,7 @@ async def _needs_upload(
13371337
entity_to_upload.file_handle.id, entity_to_upload.path
13381338
)
13391339
)
1340-
)
1340+
) and entity_to_upload.path
13411341

13421342
md5_stored_in_synapse = (
13431343
entity_to_upload.file_handle.content_md5

synapseclient/models/protocols/file_protocol.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ def store(
6161
6262
file_instance = File(path="path/to/file.txt").store(parent=Folder(id="syn456"))
6363
64+
File with an external URL and a parent folder with the ID `syn456`:
65+
66+
file_instance = File(name="my_file.txt", external_url="https://example.com/link/to/thing", parent_id="syn456", synapse_store=False).store()
67+
6468
Rename a file (Does not update the file on disk or the name of the downloaded file):
6569
6670
file_instance = File(id="syn123", download_file=False).get()

tests/unit/synapseclient/models/async/unit_test_file_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
MODIFIED_DESCRIPTION = "This is a modified description."
4545
ACTUAL_PARENT_ID = "syn999"
4646

47-
CANNOT_STORE_FILE_ERROR = "The file must have an (ID with a (path or `data_file_handle_id`)), or a (path with a (`parent_id` or parent with an id)), or a (data_file_handle_id with a (`parent_id` or parent with an id)) to store."
47+
CANNOT_STORE_FILE_ERROR = "The file must have an (ID with a (path, external_url, or `data_file_handle_id`)), or a ((path or external_url) with a (`parent_id` or parent with an id)), or a (data_file_handle_id with a (`parent_id` or parent with an id)) to store."
4848

4949

5050
class TestFile:

tests/unit/synapseclient/models/synchronous/unit_test_file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
MODIFIED_DESCRIPTION = "This is a modified description."
4444
ACTUAL_PARENT_ID = "syn999"
4545

46-
CANNOT_STORE_FILE_ERROR = "The file must have an (ID with a (path or `data_file_handle_id`)), or a (path with a (`parent_id` or parent with an id)), or a (data_file_handle_id with a (`parent_id` or parent with an id)) to store."
46+
CANNOT_STORE_FILE_ERROR = "The file must have an (ID with a (path, external_url, or `data_file_handle_id`)), or a ((path or external_url) with a (`parent_id` or parent with an id)), or a (data_file_handle_id with a (`parent_id` or parent with an id)) to store."
4747

4848

4949
class TestFile:

0 commit comments

Comments
 (0)