Skip to content

Commit 5da5517

Browse files
committed
feat: added methods for signed-url upload supabase/storage-js#152
1 parent 09e557e commit 5da5517

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

addons/supabase/Storage/storage_bucket.gd

+5-2
Original file line numberDiff line numberDiff line change
@@ -149,16 +149,19 @@ func move(source_path : String, destination_path : String) -> StorageTask:
149149
return task
150150

151151

152-
func create_signed_url(object : String, expires_in : int = 60000) -> StorageTask:
152+
func create_signed_url(object : String, expires_in : int = 60000, options: Dictionary = {
153+
download = false, transform = { format = "origin" , quality = 80 , resize = "cover" , height = 100, width = 100 }
154+
}) -> StorageTask:
153155
var endpoint : String = _config.supabaseUrl + _rest_endpoint + "sign/" + id + "/" + object
154156
var task : StorageTask = StorageTask.new()
155157
var header : PackedStringArray = [_header[0] % "application/json"]
156158
task._setup(
157159
task.METHODS.CREATE_SIGNED_URL,
158160
endpoint,
159161
header + get_parent().get_parent().get_parent().auth.__get_session_header(),
160-
JSON.stringify({expiresIn = expires_in})
162+
JSON.stringify({expiresIn = expires_in, transform = options.get("transform", {}) })
161163
)
164+
task.set_meta("options", options)
162165
_process_task(task)
163166
return task
164167

addons/supabase/Storage/storage_task.gd

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ func _on_task_completed(result : int, response_code : int, headers : PackedStrin
4040
if _code == METHODS.DOWNLOAD:
4141
complete(body)
4242
else:
43+
if _code == METHODS.CREATE_SIGNED_URL:
44+
result_body.signedURL += "&download=%s" % get_meta("options").get("download")
4345
complete(result_body)
4446
else:
4547
if result_body.is_empty():

0 commit comments

Comments
 (0)