Skip to content

Commit 7f20bb6

Browse files
committed
encoding file names to stop errors
1 parent 572249e commit 7f20bb6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/fts3_web/controllers/upload_controller.ex

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,11 @@ defmodule Fts3Web.UploadController do
318318
api_key = config[:key]
319319
bucket_name = config[:bucket]
320320

321+
# URL-encode the filename to handle spaces and special characters
322+
encoded_filename = URI.encode(filename, &URI.char_unreserved?/1)
323+
321324
# Construct the upload URL
322-
upload_url = "#{base_url}/storage/v1/object/#{bucket_name}/#{filename}"
325+
upload_url = "#{base_url}/storage/v1/object/#{bucket_name}/#{encoded_filename}"
323326

324327
# Detect content type based on file extension
325328
content_type = get_content_type(filename)

0 commit comments

Comments
 (0)