@@ -148,8 +148,25 @@ func move(source_path : String, destination_path : String) -> StorageTask:
148
148
return task
149
149
150
150
151
+ func download (object : String , to_path : String = "" , private : bool = false , options : Dictionary = {
152
+ transform = { height = 100 , width = 100 , format = "origin" , resize = "cover" , quality = 80 }
153
+ } ) -> StorageTask :
154
+ var endpoint : String = _config .supabaseUrl + _rest_endpoint + \
155
+ ("authenticated/" if private else "public/" ) + id + "/" + object + \
156
+ _get_transform_query (options .get ("transform" , {}))
157
+ var task : StorageTask = StorageTask .new ()
158
+ var header : PackedStringArray = [_header [0 ] % "application/json" ]
159
+ task ._setup (
160
+ task .METHODS .DOWNLOAD ,
161
+ endpoint ,
162
+ header + get_parent ().get_parent ().get_parent ().auth .__get_session_header ()
163
+ )
164
+ _process_task (task , {download_file = to_path })
165
+ return task
166
+
167
+
151
168
func create_signed_url (object : String , expires_in : int = 60000 , options : Dictionary = {
152
- download = "file" , transform = { format = "origin" , quality = 80 , resize = "cover" , height = 100 , width = 100 }
169
+ download = true , transform = { format = "origin" , quality = 80 , resize = "cover" , height = 100 , width = 100 }
153
170
}) -> StorageTask :
154
171
var endpoint : String = _config .supabaseUrl + _rest_endpoint + "sign/" + id + "/" + object
155
172
var task : StorageTask = StorageTask .new ()
@@ -160,46 +177,19 @@ func create_signed_url(object : String, expires_in : int = 60000, options: Dicti
160
177
header + get_parent ().get_parent ().get_parent ().auth .__get_session_header (),
161
178
JSON .stringify ({expiresIn = expires_in , transform = options .get ("transform" , {}) })
162
179
)
180
+ task .set_meta ("object" , object )
163
181
task .set_meta ("options" , options )
164
182
task .set_meta ("base_url" , _config .supabaseUrl + _rest_endpoint .replace ("/object/" , "" ))
165
183
_process_task (task )
166
184
return task
167
185
168
186
169
- func download (object : String , to_path : String = "" , private : bool = false ) -> StorageTask :
170
- if not private :
171
- var endpoint : String = _config .supabaseUrl + _rest_endpoint + "public/" + id + "/" + object
172
- var task : StorageTask = StorageTask .new ()
173
- var header : PackedStringArray = [_header [0 ] % "application/json" ]
174
- task ._setup (
175
- task .METHODS .DOWNLOAD ,
176
- endpoint ,
177
- header + get_parent ().get_parent ().get_parent ().auth .__get_session_header ()
178
- )
179
- _process_task (task , {download_file = to_path })
180
- return task
181
- else :
182
- var endpoint : String = _config .supabaseUrl + _rest_endpoint + "authenticated/" + id + "/" + object
183
- var task : StorageTask = StorageTask .new ()
184
- var header : PackedStringArray = [_header [0 ] % "application/json" ]
185
- task ._setup (
186
- task .METHODS .DOWNLOAD ,
187
- endpoint ,
188
- header + get_parent ().get_parent ().get_parent ().auth .__get_session_header ()
189
- )
190
- _process_task (task , {download_file = to_path })
191
- return task
192
-
193
-
194
- func get_public_url (object : String , transform : Dictionary = {
187
+
188
+ func get_public_url (object : String , options : Dictionary = { transform = {
195
189
height = 100 , width = 100 , format = "origin" , resize = "cover" , quality = 80
196
- } ) -> String :
190
+ } } ) -> String :
197
191
var url : String = _config .supabaseUrl + _rest_endpoint + "public/" + id + "/" + object
198
- if not transform .keys ().is_empty ():
199
- url += "?"
200
- for key in transform .keys ():
201
- url += "&%s =%s " % [key , transform .get (key )]
202
- return url
192
+ return url + _get_transform_query (options .get ("transform" , {}))
203
193
204
194
205
195
func remove (objects : PackedStringArray ) -> StorageTask :
@@ -215,6 +205,15 @@ func remove(objects : PackedStringArray) -> StorageTask:
215
205
return task
216
206
217
207
208
+
209
+ func _get_transform_query (transform : Dictionary ) -> String :
210
+ var query : String = ""
211
+ if not transform .keys ().is_empty ():
212
+ query += "?"
213
+ for key in transform .keys ():
214
+ query += "&%s =%s " % [key , transform .get (key )]
215
+ return query
216
+
218
217
func _notification (what : int ) -> void :
219
218
if what == NOTIFICATION_INTERNAL_PROCESS :
220
219
_internal_process (get_process_delta_time ())
0 commit comments