{"id":23821000,"url":"https://github.com/truesparrowsystems/go-presigned-post","last_synced_at":"2025-11-12T13:04:55.365Z","repository":{"id":219895345,"uuid":"748046711","full_name":"TrueSparrowSystems/go-presigned-post","owner":"TrueSparrowSystems","description":null,"archived":false,"fork":false,"pushed_at":"2024-02-22T06:36:54.000Z","size":100,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-21T23:26:31.414Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TrueSparrowSystems.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-25T06:49:02.000Z","updated_at":"2024-06-28T18:21:57.000Z","dependencies_parsed_at":"2024-02-16T17:36:00.504Z","dependency_job_id":"8561b042-2b73-4997-afbd-8528f926449e","html_url":"https://github.com/TrueSparrowSystems/go-presigned-post","commit_stats":null,"previous_names":["truesparrowsystems/go-presigned-post"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/TrueSparrowSystems/go-presigned-post","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrueSparrowSystems%2Fgo-presigned-post","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrueSparrowSystems%2Fgo-presigned-post/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrueSparrowSystems%2Fgo-presigned-post/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrueSparrowSystems%2Fgo-presigned-post/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TrueSparrowSystems","download_url":"https://codeload.github.com/TrueSparrowSystems/go-presigned-post/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrueSparrowSystems%2Fgo-presigned-post/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":284037610,"owners_count":26936682,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-12T02:00:06.336Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-02T08:19:40.633Z","updated_at":"2025-11-12T13:04:55.330Z","avatar_url":"https://github.com/TrueSparrowSystems.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# AWS S3 Presigned POST in Go\n\nThe `go-presigned-post` package provides a convenient way to generate a presigned POST URL to securely upload files to Amazon S3 using HTTP POST requests.\n\n## Installation\n\n```bash\ngo get -u github.com/TrueSparrowSystems/go-presigned-post\n```\n\n## Usage\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/TrueSparrowSystems/go-presigned-post\"\n)\n\nfunc main() {\n\t// Set your AWS credentials and configuration\n\tawsCredentials := presignedpost.AwsCredentialsAndConfig{\n\t\tRegion:          \"your-aws-region\",\n\t\tBucket:          \"your-s3-bucket\",\n\t\tAccessKeyID:     \"your-access-key-id\",\n\t\tSecretAccessKey: \"your-secret-access-key\",\n\t}\n\n\t// Set the key for the S3 object\n\tkey := \"path/to/upload/file.txt\"\n\n\t// Set optional policy options\n\tpolicyOptions := presignedpost.PolicyOptions{\n\t\tExpiryInSeconds:    nil, // Default is 1 hour\n\t\tContentType:        \"\",  // Content type of the S3 object\n\t\tMaxFileSizeInBytes: 0,   // Maximum allowed file size in the policy\n\t\tAcl:                \"\",  // AWS S3 ACL (Access Control List)\n\t\tCacheControl:       \"\",  // Cache control header\n\t}\n\n\t// Generate presigned POST URL and fields\n\tpostUrl, postFields, err := presignedpost.PresignedPostObject(key, awsCredentials, policyOptions)\n\tif err != nil {\n\t\tfmt.Println(\"Error:\", err)\n\t\treturn\n\t}\n\n\t// Use postUrl and postFields to upload a file using HTTP POST\n\t// ...\n\n\tfmt.Println(\"Presigned POST URL:\", postUrl)\n\tfmt.Println(\"Presigned POST Fields:\", postFields)\n}\n```\n\n## Documentation\n\n### `PresignedPostObject`\n\n```go\nfunc PresignedPostObject(key string, awsCredentialsAndConfig presignedpost.AwsCredentialsAndConfig, policyOpts presignedpost.PolicyOptions) (string, presignedpost.PresignedPostRequestFields, error)\n```\n\nGenerates a presigned POST URL and fields for uploading a file to S3.\n\n- `key`: Key (file path) for the S3 object.\n- `awsCredentialsAndConfig`: AWS credentials and configuration.\n- `policyOpts`: Policy options (expiration time, content type, etc.).\n\n### `AwsCredentialsAndConfig`\n\n```go\ntype AwsCredentialsAndConfig struct {\n\tRegion          string // AWS region.\n\tBucket          string // AWS S3 bucket.\n\tAccessKeyID     string // AWS access key.\n\tSecretAccessKey string // AWS secret access key.\n}\n```\n\n### `PolicyOptions`\n\n```go\ntype PolicyOptions struct {\n\tExpiryInSeconds     *int    // Expiration time in seconds for the policy. Default is 3600.\n\tContentType         string  // Content type of the S3 object.\n\tMaxFileSizeInBytes  int     // Maximum allowed file size in the policy.\n\tAcl                 string  // AWS S3 ACL (Access Control List). Default is private.\n\tCacheControl        string  // Cache control header. Default is none.\n}\n```\n\n### `PresignedPostRequestFields`\n\n```go\ntype PresignedPostRequestFields struct {\n\tKey            string `json:\"key\"`              // S3 object key.\n\tBucket         string `json:\"bucket\"`           // S3 bucket.\n\tXAmzAlgorithm  string `json:\"X-Amz-Algorithm\"`  // AWS algorithm header.\n\tXAmzCredential string `json:\"X-Amz-Credential\"` // AWS credential header.\n\tXAmzDate       string `json:\"X-Amz-Date\"`       // AWS date header.\n\tPolicy         string `json:\"Policy\"`           // Base64-encoded policy.\n\tXAmzSignature  string `json:\"X-Amz-Signature\"`  // AWS signature header.\n\tContentType    string `json:\"Content-Type\"`     // Content type header.\n\tCacheControl   string `json:\"Cache-Control\"`    // Cache control header.\n\tAcl            string `json:\"acl\"`              // AWS S3 ACL header.\n}\n```\n\n## Contribution\n\nWe welcome more helping hands to make the package better. Feel free to report issues, and raise PRs for fixes \u0026 enhancements.\n\n\u003cp align=\"left\"\u003eBuilt with :heart: by \u003ca href=\"https://truesparrow.com/\" target=\"_blank\"\u003eTrue Sparrow\u003c/a\u003e\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftruesparrowsystems%2Fgo-presigned-post","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftruesparrowsystems%2Fgo-presigned-post","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftruesparrowsystems%2Fgo-presigned-post/lists"}