@@ -74,12 +74,31 @@ def test_get_success(self, tmp_path: pathlib.Path):
74
74
operation = ShareLinkOperation .download ,
75
75
expire = arrow .utcnow ().shift (hours = 1 )
76
76
)
77
+ assert 'output_path' not in url
77
78
78
79
resp = self .client .get (url , headers = {'StorageRoot' : str (tmp_path )})
79
80
assert resp .status_code == 200
80
81
assert resp .content_type == 'application/octet-stream'
81
82
assert resp .body == b'foo'
82
83
84
+ def test_get_with_output_path (self , tmp_path : pathlib .Path ):
85
+ storage = create_local_storage (tmp_path )
86
+ storage .upload (io .BytesIO (b'foo' ), 'abc.txt' )
87
+ assert tmp_path .joinpath ('abc.txt' ).exists ()
88
+
89
+ url = storage .link_to (
90
+ path = 'abc.txt' ,
91
+ operation = ShareLinkOperation .download ,
92
+ expire = arrow .utcnow ().shift (hours = 1 ),
93
+ output_path = 'myfile.txt' ,
94
+ )
95
+
96
+ resp = self .client .get (url , headers = {'StorageRoot' : str (tmp_path )})
97
+ assert resp .status_code == 200
98
+ assert resp .content_type == 'application/octet-stream'
99
+ assert resp .content_disposition == 'attachment; filename=myfile.txt'
100
+ assert resp .body == b'foo'
101
+
83
102
@pytest .mark .parametrize ('method' , ['post' , 'put' ])
84
103
def test_post_put_operation_not_allowed (self , tmp_path : pathlib .Path , method : str ):
85
104
storage = create_local_storage (tmp_path )
0 commit comments