This commit is contained in:
2026-09-05 10:00:36 +07:00
parent 25ca9b96a2
commit 9ad732c436
8 changed files with 319 additions and 24 deletions
+130
View File
@@ -0,0 +1,130 @@
curl -X PUT -H "Content-Type: application/json" \
-d '{"test": "data"}' \
"https://s3-api.yiem.cc/sommpanion/pcimage.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=GKb080154a2e5b19100b1b2c6e%2F20260904%2Fgarage%2Fs3%2Faws4_request&X-Amz-Date=20260904T103745Z&X-Amz-Expires=300&X-Amz-Security-Token=&X-Amz-SignedHeaders=host&X-Amz-Signature=0e195a48f824a2f8ffcb06461396cd6a8bddd5b61d93e9006f947ae10ecf525f"
curl -v -X PUT -T "/home/ton/docker-apps/sommpanion/etc/GeneralUtils/photo.jpg" \
-H 'Host: s3-api.yiem.cc' \
-H 'Content-Type: image/jpeg' \
"https://s3-api.yiem.cc/sommpanion/photo.jpg?X-Amz-Expires=3600&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=GKb080154a2e5b19100b1b2c6e%2F20260905%2Fgarage%2Fs3%2Faws4_request&X-Amz-Date=20260905T025455Z&X-Amz-SignedHeaders=host&X-Amz-Signature=92e86746a92fa07914d8f08169dac66e2c64f36b807f86504bf8efec41fed153"
read
./garage.toml
./Caddyfile
./src/garageS3.jl
julia> url = GeneralUtils.s3_sign_url(storage1, "photo.jpg", 36000; verb="PUT", content_type="image/jpeg")
"https://s3-api.yiem.cc/sommpanion/photo.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=GKb080154a2e5b19100b1b2c6e%2F20260904%2Fgarage%2Fs3%2Faws4_request&X-Amz-Date=20260904T145004Z&X-Amz-Expires=36000&X-Amz-SignedHeaders=content-type%3Bhost&X-Amz-Signature=92cd634dbb0f66db4b8b039ef5939c138203de260e8342fe27ef78979d90a824"
---
ton@server12vm-dev:~/docker-apps/sommpanion/etc/AWS.jl$
curl -v -X PUT -T "/home/ton/docker-apps/sommpanion/etc/GeneralUtils/photo.jpg" \
-H 'Host: s3-api.yiem.cc' \
-H 'Content-Type: image/jpeg' \
"https://s3-api.yiem.cc/sommpanion/photo.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=GKb080154a2e5b19100b1b2c6e%2F20260904%2Fgarage%2Fs3%2Faws4_request&X-Amz-Date=20260904T152217Z&X-Amz-Expires=36000&X-Amz-SignedHeaders=content-type%3Bhost&X-Amz-Signature=7eb874abb813427a71beab956514c3a0539cacf765013aa194be8517dd081f02"
Note: Unnecessary use of -X or --request, PUT is already inferred.
* Trying 110.77.160.154:443...
* Connected to s3-api.yiem.cc (110.77.160.154) port 443 (#0)
* ALPN: offers h2,http/1.1
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* CAfile: /etc/ssl/certs/ca-certificates.crt
* CApath: /etc/ssl/certs
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_CHACHA20_POLY1305_SHA256
* ALPN: server accepted h2
* Server certificate:
* subject: CN=s3-api.yiem.cc
* start date: Aug 27 04:27:02 2026 GMT
* expire date: Nov 25 04:27:01 2026 GMT
* subjectAltName: host "s3-api.yiem.cc" matched cert's "s3-api.yiem.cc"
* issuer: C=US; O=Let's Encrypt; CN=YE2
* SSL certificate verify ok.
* using HTTP/2
* h2h3 [:method: PUT]
* h2h3 [:path: /sommpanion/photo.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=GKb080154a2e5b19100b1b2c6e%2F20260904%2Fgarage%2Fs3%2Faws4_request&X-Amz-Date=20260904T152217Z&X-Amz-Expires=36000&X-Amz-SignedHeaders=content-type%3Bhost&X-Amz-Signature=7eb874abb813427a71beab956514c3a0539cacf765013aa194be8517dd081f02]
* h2h3 [:scheme: https]
* h2h3 [:authority: s3-api.yiem.cc]
* h2h3 [user-agent: curl/7.88.1]
* h2h3 [accept: */*]
* h2h3 [content-type: image/jpeg]
* h2h3 [content-length: 439490]
* Using Stream ID: 1 (easy handle 0x559a08824c80)
> PUT /sommpanion/photo.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=GKb080154a2e5b19100b1b2c6e%2F20260904%2Fgarage%2Fs3%2Faws4_request&X-Amz-Date=20260904T152217Z&X-Amz-Expires=36000&X-Amz-SignedHeaders=content-type%3Bhost&X-Amz-Signature=7eb874abb813427a71beab956514c3a0539cacf765013aa194be8517dd081f02 HTTP/2
> Host: s3-api.yiem.cc
> user-agent: curl/7.88.1
> accept: */*
> content-type: image/jpeg
> content-length: 439490
>
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* We are completely uploaded and fine
< HTTP/2 403
< access-control-allow-origin: *
< alt-svc: h3=":443"; ma=2592000
< content-type: application/xml
< date: Fri, 04 Sep 2026 15:23:13 GMT
< via: 1.1 Caddy
< content-length: 190
<
* Connection #0 to host s3-api.yiem.cc left intact
<?xml version="1.0" encoding="UTF-8"?><Error><Code>AccessDenied</Code><Message>Forbidden: Invalid signature</Message><Resource>/sommpanion/photo.jpg</Resource><Region>garage</Region></Error>
2026-09-04T15:23:13.796037Z INFO garage_api_common::generic_server: 110.77.160.154 (via 192.168.88.21:57926) PUT /sommpanion/photo.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=GKb080154a2e5b19100b1b2c6e%2F20260904%2Fgarage%2Fs3%2Faws4_request&X-Amz-Date=20260904T152217Z&X-Amz-Expires=36000&X-Amz-SignedHeaders=content-type%3Bhost&X-Amz-Signature=7eb874abb813427a71beab956514c3a0539cacf765013aa194be8517dd081f02
2026-09-04T15:23:13.796077Z DEBUG garage_api_common::generic_server: Request { method: PUT, uri: /sommpanion/photo.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=GKb080154a2e5b19100b1b2c6e%2F20260904%2Fgarage%2Fs3%2Faws4_request&X-Amz-Date=20260904T152217Z&X-Amz-Expires=36000&X-Amz-SignedHeaders=content-type%3Bhost&X-Amz-Signature=7eb874abb813427a71beab956514c3a0539cacf765013aa194be8517dd081f02, version: HTTP/1.1, headers: {"host": "s3-api.yiem.cc", "user-agent": "curl/7.88.1", "content-length": "439490", "accept": "*/*", "content-type": "image/jpeg", "via": "2.0 Caddy", "x-forwarded-for": "110.77.160.154", "x-forwarded-host": "s3-api.yiem.cc", "x-forwarded-proto": "https", "accept-encoding": "gzip"}, body: Body(Streaming) }
2026-09-04T15:23:13.796181Z DEBUG garage_api_common::generic_server: Endpoint: PutObject
2026-09-04T15:23:13.796461Z INFO garage_api_common::generic_server: error 403 Forbidden, Forbidden: Invalid signature in response to 110.77.160.154 (via 192.168.88.21:57926) PUT /sommpanion/photo.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=GKb080154a2e5b19100b1b2c6e%2F20260904%2Fgarage%2Fs3%2Faws4_request&X-Amz-Date=20260904T152217Z&X-Amz-Expires=36000&X-Amz-SignedHeaders=content-type%3Bhost&X-Amz-Signature=7eb874abb813427a71beab956514c3a0539cacf765013aa194be8517dd081f02
+11 -13
View File
@@ -2,8 +2,6 @@ using Test
using GeneralUtils
using GeneralUtils.garageS3
using AWS
using Random: randstring
using UUIDs: uuid4
using URIs
@testset "garageS3.jl" begin
@@ -143,7 +141,7 @@ using URIs
"testbucket"
)
test_key = "testrunner-$(randstring(8)).json"
test_key = "testrunner-$(GeneralUtils.uuid4snakecase()).json"
test_data = "{\"status\": \"testing\", \"runner\": \"runtests\"}"
# Test put_file(storage, key, data) - successful upload
@@ -166,7 +164,7 @@ using URIs
@test test_key in keys
# Test put_file callable struct
test_key2 = "testrunner-callable-$(randstring(8)).json"
test_key2 = "testrunner-callable-$(GeneralUtils.uuid4snakecase()).json"
callable_result = put_file(storage)(test_key2, "callable-data")
@test callable_result !== nothing
@test callable_result.api != ""
@@ -195,7 +193,7 @@ using URIs
"testbucket"
)
test_key = "single/slash/test-$(randstring(8)).json"
test_key = "single/slash/test-$(GeneralUtils.uuid4snakecase()).json"
test_data = "{\"level\": 1, \"nested\": true}"
# Upload nested key
@@ -228,7 +226,7 @@ using URIs
"testbucket"
)
test_key = "deep/nested/folder/subfolder/test-$(randstring(8)).json"
test_key = "deep/nested/folder/subfolder/test-$(GeneralUtils.uuid4snakecase()).json"
test_data = "{\"deeply\": \"nested\", \"path\": \"deep/nested/folder/subfolder/\"}"
# Upload deeply nested key
@@ -260,7 +258,7 @@ using URIs
"testbucket"
)
test_key = "callable/nested/test-$(randstring(8)).json"
test_key = "callable/nested/test-$(GeneralUtils.uuid4snakecase()).json"
test_data = "{\"callable\": true, \"nested\": true}"
uploader = put_file(storage)
@@ -282,7 +280,7 @@ using URIs
"a2c6b1379c2f731d3e6e5a408dd4d6cffca7511717675f55114ff94828febca1",
"testbucket"
)
result = get_file(storage, "nonexistent-key-$(randstring(8)).json")
result = get_file(storage, "nonexistent-key-$(GeneralUtils.uuid4snakecase()).json")
@test result === nothing
end
@@ -294,7 +292,7 @@ using URIs
"testbucket"
)
test_key = "testrunner-binary-$(randstring(8)).bin"
test_key = "testrunner-binary-$(GeneralUtils.uuid4snakecase()).bin"
binary_data = UInt8[0x00, 0x01, 0x02, 0xFF, 0xFE, 0xFD, 0x48, 0x65, 0x6c, 0x6c, 0x6f]
result = put_file(storage, test_key, binary_data)
@@ -315,7 +313,7 @@ using URIs
"testbucket"
)
test_key = "testrunner-list-$(randstring(8)).txt"
test_key = "testrunner-list-$(GeneralUtils.uuid4snakecase()).txt"
put_file(storage, test_key, "list-test-data")
keys = list_files(storage)
@@ -333,7 +331,7 @@ using URIs
"testbucket"
)
test_key = "testrunner-url-$(randstring(8)).json"
test_key = "testrunner-url-$(GeneralUtils.uuid4snakecase()).json"
result = put_file(storage, test_key, "url-test")
@test startswith(result.api, "https://s3-api.yiem.cc/testbucket/")
@@ -576,8 +574,8 @@ using URIs
"testbucket"
)
test_key = "testrunner-presign-$(randstring(8)).json"
test_data = "{\"presign\": true, \"test\": \"$(randstring(12))\"}"
test_key = "testrunner-presign-$(GeneralUtils.uuid4snakecase()).json"
test_data = "{\"presign\": true, \"test\": \"$(GeneralUtils.uuid4snakecase())\"}"
put_file(storage, test_key, test_data)
url = s3_sign_url(storage, test_key, 300)
Binary file not shown.

After

Width:  |  Height:  |  Size: 429 KiB