diff --git a/src/garageS3.jl b/src/garageS3.jl index 47510e1..b754213 100644 --- a/src/garageS3.jl +++ b/src/garageS3.jl @@ -1,20 +1,19 @@ module garageS3 export - GarageStorage, - put_file, - get_file, - list_files, - delete_file + GarageStorage, put_file, get_file, list_files, delete_file, + set_lifecycle_expiration, get_lifecycle, delete_lifecycle -using AWS, AWSS3 +using AWS +@service S3 +using AWSS3 # ---------------------------------------------- 100 --------------------------------------------- # # Garage uses Path-Style routing (https://s3-api.my-domain.com/bucket/key). # this file use local AWS config """ Example -storage = GarageStorage( +storage = GeneralUtils.GarageStorage( "https://s3-api.yiem.cc", "GKb080154a2e5b19100b1b2c6e", # key ID (create at garage-ui.yiem.cc) "a2c6b1379c2f731d3e6e5a408dd4d6cffca7511717675f55114ff94828febca1", # key ID's secret key @@ -22,9 +21,8 @@ storage = GarageStorage( ) # Safe to run inside concurrent HTTP handlers (e.g., Oxygen.jl, HTTP.jl) -put_file(storage, "users-1005.json", "{\"status\": \"active\"}") -keys = list_files(storage) -data = String(get_file(storage, "users-1004.json")) +GeneralUtils.put_file(storage, "users-1005.json", "{\"status\": \"active\"}") +keys = GeneralUtils.list_files(storage) println("Read back: ", data) println("Bucket keys: ", keys) @@ -35,7 +33,7 @@ curl -v \ http://192.168.88.106:3902/users-1002.json # test with API -data = String(get_file(storage, "users-1005.json")) +data = String(GeneralUtils.get_file(storage, "users-1005.json")) # test with a browser https://s3-web.mydomain.com/my_bucket_name/users-1005.json @@ -176,7 +174,7 @@ function (pf::put_file)(key::String, data::Union{String, Vector{UInt8}})::String end # Proceed if the key is flat - s3_put(pf.storage.config, pf.storage.bucket, key, data) + AWSS3.s3_put(pf.storage.config, pf.storage.bucket, key, data) println("Successfully uploaded: ", key) # file download URL @@ -217,7 +215,7 @@ function put_file(storage::GarageStorage, key::String, data::Union{String, Vecto end # Proceed if the key is flat - s3_put(storage.config, storage.bucket, key, data) + AWSS3.s3_put(storage.config, storage.bucket, key, data) println("Successfully uploaded: ", key) # file download URL @@ -244,7 +242,7 @@ julia> data = String(get_file(storage, "test.json")) ``` """ function get_file(storage::GarageStorage, key::String)::Vector{UInt8} - return s3_get(storage.config, storage.bucket, key) + return AWSS3.s3_get(storage.config, storage.bucket, key) end """ List all object keys in the Garage S3 bucket. @@ -267,7 +265,7 @@ julia> keys = list_files(storage) """ function list_files(storage::GarageStorage) # Approach 2: s3_list_objects returns a Vector of Dicts with object details - objects = s3_list_objects(storage.config, storage.bucket) + objects = AWSS3.s3_list_objects(storage.config, storage.bucket) return [obj["Key"] for obj in objects] end @@ -285,7 +283,7 @@ julia> delete_file(storage, "test.json") ``` """ function delete_file(storage::GarageStorage, key::String) - s3_delete(storage.config, storage.bucket, key) + AWSS3.s3_delete(storage.config, storage.bucket, key) end @@ -296,11 +294,4 @@ end - - - - - - - end # module GarageS3