package aws-s3

  1. Overview
  2. Docs

Module S3.MakeSource

S3 functions All function requires a region, scheme and credentials.

The default region is Us_east_1.

The default scheme is http. If you are connecting from outside AWS, it is strongly recommended that you use https. To use https, make sure to have the relevant opam packages installed: async_ssl for async and lwt_ssl/tls for lwt. Please note that connections are not reused due to a limitation on the AWS endpoint.

If no credentials is provided, the requests will not be signed, The bucket / objects need to be configured accordingly.

Parameters

module Io : Types.Io

Signature

Sourcetype error =
  1. | Redirect of Region.endpoint
  2. | Throttled
  3. | Unknown of int * string
  4. | Failed of exn
  5. | Forbidden
  6. | Not_found
Sourcetype etag = string
Sourcetype storage_class =
  1. | Standard
  2. | Standard_ia
  3. | Onezone_ia
  4. | Reduced_redundancy
  5. | Glacier
Sourcetype content = {
  1. storage_class : storage_class;
  2. size : int;
  3. last_modified : float;
    (*

    Seconds since epoch

    *)
  4. key : string;
  5. etag : etag;
    (*

    Etag as a string. this us usually the MD5, unless the object was constructed by multi-upload

    *)
  6. meta_headers : (string * string) list option;
    (*

    Meta headers. If None, the information was not retrieved.

    *)
}
Sourcetype nonrec 'a result = ('a, error) result Io.Deferred.t
Sourcetype 'a command = ?credentials:Credentials.t -> ?connect_timeout_ms:int -> ?confirm_requester_pays:bool -> endpoint:Region.endpoint -> 'a

The type of S3 requests. credentials refers to AWS credentials, as created by Credentials.make. connect_timeout_ms specifies the request timeout, in milliseconds. If confirm_requester_pays, caller acknowledges that it will pay AWS data transfer costs, should the target bucket be so configured. endpoint encapsulates the AWS endpoint, as created by Region.endpoint.

Sourcemodule Ls : sig ... end
Sourcemodule Delete_multi : sig ... end
Sourcetype range = {
  1. first : int option;
  2. last : int option;
}
Sourceval put : (?content_type:string -> ?content_encoding:string -> ?acl:string -> ?cache_control:string -> ?expect:bool -> ?meta_headers:(string * string) list -> bucket:string -> key:string -> data:string -> unit -> etag result) command

Upload data to bucket/key. Returns the etag of the object. The etag is the md5 checksum (RFC 1864)

  • parameter expect

    If true, the body will not be sent until a status has been received from the server. This incurs a delay in transfer, but avoid sending a large body, if the request can be know to fail before the body is sent.

  • parameter meta_headers

    Can be used to set User-defined object metadata. arguments are expected to be a list of key-value pairs, the keys will be prefixed with "x-amz-meta-". @see https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingMetadata.html#UserMetadata

Sourceval get : (?range:range -> bucket:string -> key:string -> unit -> string result) command

Download key from s3 in bucket If range is specified, only a part of the file is retrieved:

  • If first is None, then start from the beginning of the object.
  • If last is None, then get to the end of the object.
Sourceval head : (bucket:string -> key:string -> unit -> content result) command

Call head on the object to retrieve info on a single object

Sourceval delete : (bucket:string -> key:string -> unit -> unit result) command

Delete key from bucket.

Sourceval delete_multi : (bucket:string -> objects:Delete_multi.objekt list -> unit -> Delete_multi.result result) command

Delete multiple objects from bucket.

The result will indicate which items failed and which are deleted. If an item is not found it will be reported as successfully deleted (the operation is idempotent).

Sourceval ls : (?start_after:string -> ?continuation_token:string -> ?prefix:string -> ?max_keys:int -> bucket:string -> unit -> Ls.t) command

List contents in bucket Aws will return at most 1000 keys per request. If not all keys are returned, the function will return a continuation.

Keys in s3 are stored in lexicographical order, and also returned as such.

If a continuation_token is given the result will continue from last call.

If start_after is given then keys only keys after start_with are returned. Note that is both start_after and a continuation_token is given then start_after argument is ignored.

If prefix is given, then only keys starting with the given prefix will be returned.

Sourcemodule Stream : sig ... end

Streaming functions. Streaming function seeks to limit the amount of used memory used when operating of large objects by operating on streams.

Sourcemodule Multipart_upload : sig ... end
Sourceval retry : endpoint:Region.endpoint -> retries:int -> f:(endpoint:Region.endpoint -> unit -> 'a result) -> unit -> 'a result

Helper function to handle error codes. The function handle redirects and throttling.

OCaml

Innovation. Community. Security.