init commit
All checks were successful
Build and Publish / build-release (push) Successful in 4m46s

This commit is contained in:
2026-04-15 15:31:56 -05:00
commit f566d04a04
41 changed files with 2430 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
defmodule ProviderService.S3 do
@bucket Application.compile_env(:provider_service, :s3_bucket, "policy-bucket")
def presigned_upload_url(s3_key) do
{:ok, url} =
ExAws.Config.new(:s3)
|> ExAws.S3.presigned_url(:put, @bucket, s3_key,
expires_in: 900,
query_params: [{"Content-Type", "application/pdf"}]
)
url
end
def presigned_download_url(s3_key) do
{:ok, url} =
ExAws.Config.new(:s3)
|> ExAws.S3.presigned_url(:get, @bucket, s3_key, expires_in: 3600)
url
end
def delete(s3_key) do
ExAws.S3.delete_object(@bucket, s3_key)
|> ExAws.request()
end
def upload(local_path, s3_key) do
local_path
|> File.read!()
|> then(&ExAws.S3.put_object(@bucket, s3_key, &1, content_type: "application/pdf"))
|> ExAws.request()
|> case do
{:ok, _} -> :ok
{:error, e} -> {:error, inspect(e)}
end
end
end