README
¶
Static File Upload Client
Usage
Setup
Local:
c := upload.NewAPIClient("http://localhost:25100")
Remote:
c := upload.NewAPIClient("http://localhost:11850")
Uploading a file
f := io.NopCloser(strings.NewReader("File content"))
m := upload.Metadata{
CollectionID: &collectionID, // Collection ID is option. Leave it unset if you do not have it at upload
FileName: "test.txt",
Path: "testing/docs",
IsPublishable: true,
Title: "A testing file",
FileSizeBytes: 12,
FileType: "text/plain",
License: "MIT",
LicenseURL: "https://opensource.org/licenses/MIT",
}
err := c.Upload(f, m)
if err != nil {
...
}
Notes:
- all fields are required, except collection Id
- but it must be set before publishing
- see https://github.com/ONSdigital/dp-api-clients-go/tree/main/files
- File name will be part of the AWS S3 object name so should adhere to the S3 object naming guidelines
- Path will be part of the AWS S3 bucket name so should adhere to the S3 bucket naming rules
- FileType is the the mime type of the file being uploaded
- used when file is downloaded
Documentation
¶
Index ¶
Constants ¶
View Source
const (
MaxFileSize = chunkSize * maxChunks
)
Variables ¶
View Source
var ( ErrFileTooLarge = fmt.Errorf("file too large, max file size: %d MB", MaxFileSize>>20) ErrNotAuthorized = errors.New("you are not authorized for this action") )
Functions ¶
This section is empty.
Types ¶
type ChunkContext ¶ added in v2.101.0
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an upload API client which can be used to make requests to the server. It extends the generic healthcheck Client structure.
func NewAPIClient ¶
NewAPIClient creates a new instance of Upload Client with a given image API URL
Click to show internal directories.
Click to hide internal directories.