Core S3 HTTP operations module providing direct access to S3-compatible object storage.
This module provides low-level HTTP-based operations for interacting with S3-compatible object storage services. It uses system curl commands to perform GET, PUT, DELETE, and HEAD HTTP operations.
use s3_http
type(s3_config) :: config
character(len=:), allocatable :: content
logical :: success
! Configure and initialize
config%bucket = 'my-bucket'
config%region = 'us-east-1'
config%use_https = .true.
call s3_init(config)
! Download object
success = s3_get_object('data/file.txt', content)
Note
This module requires the curl
command to be available in the system PATH.
Warning
URL encoding of special characters in S3 keys is not currently supported.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
type(s3_config), | private, | save | :: | current_config | |||
logical, | private, | save | :: | initialized | = | .false. |
S3 configuration type containing connection parameters and credentials.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
character(len=256), | public | :: | bucket | = | '' | ||
character(len=256), | public | :: | region | = | 'us-east-1' | ||
character(len=256), | public | :: | endpoint | = | 's3.amazonaws.com' | ||
character(len=256), | public | :: | access_key | = | '' | ||
character(len=256), | public | :: | secret_key | = | '' | ||
logical, | public | :: | use_https | = | .true. |
Download an object from S3 and return its content.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | key | |||
character(len=:), | intent(out), | allocatable | :: | content |
Fallback implementation using temporary files.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | key | |||
character(len=:), | intent(out), | allocatable | :: | content |
Upload an object to S3.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | key | |||
character(len=*), | intent(in) | :: | content |
Check if an object exists in S3.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | key |
Delete an object from S3.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | key |
Download an object using an s3:// URI.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | uri | |||
character(len=:), | intent(out), | allocatable | :: | content |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | uri |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | uri | |||
character(len=*), | intent(in) | :: | content |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | uri |
Parse an s3:// URI into bucket name and object key components.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | uri | |||
character(len=:), | intent(out), | allocatable | :: | bucket | ||
character(len=:), | intent(out), | allocatable | :: | key | ||
logical, | intent(out) | :: | success |
Initialize the S3 HTTP module with configuration.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(s3_config), | intent(in) | :: | config |