# README
Static File Upload Client
Usage
Setup
Local:
c := files.NewAPIClient("http://localhost:26900")
If using a healthcheck client, it can be instantiated as follows:
import "github.com/ONSdigital/dp-api-clients-go/v2/health"
hcClient := health.NewClient("api-router", "http://localhost:26900")
c := files.NewWithHealthClient(hcClient)
c.Version = "v1"
Here you will notice that the version has been set for the files
client. This is important as it will prepend this to GetFile
requests. I.e. /{.Version}/files/*
.
Remote:
c := files.NewAPIClient("http://localhost:12700")
Set collection ID
err := c.SetCollectionID(context.Background(), "testing/test.txt", "123456789")
if err != nil {
...
}
Publish Collection
err := c.PublishCollection(context.Background(), "123456789")
if err != nil {
...
}
Get File by Path
result, err := client.GetFile(context.Background(), "test/testing.csv", "AUTH TOKEN")
if err != nil {
...
}
if result.IsPublshable {
...
}