upload

package
v2.8.1-rc.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UploadToS3

func UploadToS3(ctx context.Context, filePath string, form PresignedUploadForm) error

UploadToS3 uploads a file to S3 using a presigned POST form.

The presigned form fields handle S3 authorisation. No bearer token or additional auth headers are needed -- the POST goes directly to S3.

The form data fields must be sent BEFORE the file field. S3 requires this ordering for presigned POSTs.

The multipart body is buffered in memory so the HTTP client can set the Content-Length header, which S3 requires for presigned POST uploads.

Types

type PresignedUploadForm

type PresignedUploadForm struct {
	Method    string            `json:"method"`
	URL       string            `json:"url"`
	Data      map[string]string `json:"data"`
	FileInput string            `json:"file_input"`
}

PresignedUploadForm describes the S3 presigned POST form returned by the Buildkite API. All Data fields must be sent as form fields before the file.

type S3ForbiddenError

type S3ForbiddenError struct {
	Status int
	Body   string
}

S3ForbiddenError is returned when S3 rejects the upload with 403 Forbidden. Callers can use errors.As to detect this case and re-fetch the presigned URL before retrying; the most common cause is a presigned POST policy that has reached its expiration. Other 4xx responses surface as the generic upload error. The Body field preserves the raw S3 response so the original error remains diagnosable in logs.

func (*S3ForbiddenError) Error

func (e *S3ForbiddenError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL