From c4741140f53201b9562899d4265f3137517e0a79 Mon Sep 17 00:00:00 2001 From: narawat Date: Fri, 28 Aug 2026 08:28:35 +0700 Subject: [PATCH] update --- src/garageS3.jl | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/garageS3.jl b/src/garageS3.jl index f213500..8364771 100644 --- a/src/garageS3.jl +++ b/src/garageS3.jl @@ -168,7 +168,7 @@ Successfully uploaded: test.json struct put_file storage::GarageStorage end -function (pf::put_file)(key::String, data::Union{String, Vector{UInt8}}) +function (pf::put_file)(key::String, data::Union{String, Vector{UInt8}})::String # Check if the key contains a slash (virtual folder character) if occursin('/', key) @warn "Upload aborted! Slashes ('/') are not allowed in keys ('$key') to prevent S3 listing issues. Use a flat naming convention instead (e.g., 'users-1002.json')." @@ -209,16 +209,21 @@ julia> put_file(storage, "test.json", "{\"status\": \"active\"}") Successfully uploaded: test.json ``` """ -function put_file(storage::GarageStorage, key::String, data::Union{String, Vector{UInt8}}) - # Check if the key contains a slash (virtual folder character) - if occursin('/', key) - @warn "Upload aborted! Slashes ('/') are not allowed in keys ('$key') to prevent S3 listing issues. Use a flat naming convention instead (e.g., 'users-1002.json')." - return nothing - end - - # Proceed if the key is flat - s3_put(storage.config, storage.bucket, key, data) - println("Successfully uploaded: ", key) +function put_file(storage::GarageStorage, key::String, data::Union{String, Vector{UInt8}})::String + # Check if the key contains a slash (virtual folder character) + if occursin('/', key) + @warn "Upload aborted! Slashes ('/') are not allowed in keys ('$key') to prevent S3 listing issues. Use a flat naming convention instead (e.g., 'users-1002.json')." + return nothing + end + + # Proceed if the key is flat + s3_put(storage.config, storage.bucket, key, data) + println("Successfully uploaded: ", key) + + # file download URL + objURL = "$(pf.storage.config.endpoint)/$(pf.storage.bucket)/$key" + + return objURL end """ Download an object from the Garage S3 bucket.