(Files)
- List - List Files
- Create - Create File
- Uploaded - Complete File Upload
- Update - Update File
- Delete - Delete File
List files.
package main
import(
"context"
"os"
polargo "github.com/polarsource/polar-go"
"log"
)
func main() {
ctx := context.Background()
s := polargo.New(
polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
)
res, err := s.Files.List(ctx, nil, nil, nil, nil)
if err != nil {
log.Fatal(err)
}
if res.ListResourceFileRead != nil {
for {
// handle items
res, err = res.Next()
if err != nil {
// handle error
}
if res == nil {
break
}
}
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
organizationID |
*string | ➖ | N/A |
ids |
[]string | ➖ | List of file IDs to get. |
page |
*int64 | ➖ | Page number, defaults to 1. |
limit |
*int64 | ➖ | Size of a page, defaults to 10. Maximum is 100. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.FilesListResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.HTTPValidationError | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |
Create a file.
package main
import(
"context"
"os"
polargo "github.com/polarsource/polar-go"
"github.com/polarsource/polar-go/models/components"
"log"
)
func main() {
ctx := context.Background()
s := polargo.New(
polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
)
res, err := s.Files.Create(ctx, components.CreateFileCreateProductMediaFileCreate(
components.ProductMediaFileCreate{
Name: "<value>",
MimeType: "<value>",
Size: 951062,
Upload: components.S3FileCreateMultipart{
Parts: []components.S3FileCreatePart{
components.S3FileCreatePart{
Number: 86,
ChunkStart: 169727,
ChunkEnd: 89964,
},
},
},
},
))
if err != nil {
log.Fatal(err)
}
if res.FileUpload != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
components.FileCreate | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.FilesCreateResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.HTTPValidationError | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |
Complete a file upload.
package main
import(
"context"
"os"
polargo "github.com/polarsource/polar-go"
"github.com/polarsource/polar-go/models/components"
"log"
)
func main() {
ctx := context.Background()
s := polargo.New(
polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
)
res, err := s.Files.Uploaded(ctx, "<value>", components.FileUploadCompleted{
ID: "<id>",
Path: "/sys",
Parts: []components.S3FileUploadCompletedPart{
components.S3FileUploadCompletedPart{
Number: 173116,
ChecksumEtag: "<value>",
ChecksumSha256Base64: polargo.String("<value>"),
},
components.S3FileUploadCompletedPart{
Number: 894030,
ChecksumEtag: "<value>",
ChecksumSha256Base64: polargo.String("<value>"),
},
components.S3FileUploadCompletedPart{
Number: 673715,
ChecksumEtag: "<value>",
ChecksumSha256Base64: polargo.String("<value>"),
},
},
})
if err != nil {
log.Fatal(err)
}
if res.ResponseFilesUploaded != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
id |
string | ✔️ | The file ID. |
fileUploadCompleted |
components.FileUploadCompleted | ✔️ | N/A |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.FilesUploadedResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.NotPermitted | 403 | application/json |
apierrors.ResourceNotFound | 404 | application/json |
apierrors.HTTPValidationError | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |
Update a file.
package main
import(
"context"
"os"
polargo "github.com/polarsource/polar-go"
"github.com/polarsource/polar-go/models/components"
"log"
)
func main() {
ctx := context.Background()
s := polargo.New(
polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
)
res, err := s.Files.Update(ctx, "<value>", components.FilePatch{})
if err != nil {
log.Fatal(err)
}
if res.ResponseFilesUpdate != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
id |
string | ✔️ | The file ID. |
filePatch |
components.FilePatch | ✔️ | N/A |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.FilesUpdateResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.NotPermitted | 403 | application/json |
apierrors.ResourceNotFound | 404 | application/json |
apierrors.HTTPValidationError | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |
Delete a file.
package main
import(
"context"
"os"
polargo "github.com/polarsource/polar-go"
"log"
)
func main() {
ctx := context.Background()
s := polargo.New(
polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
)
res, err := s.Files.Delete(ctx, "<value>")
if err != nil {
log.Fatal(err)
}
if res != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
id |
string | ✔️ | N/A |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.FilesDeleteResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.NotPermitted | 403 | application/json |
apierrors.ResourceNotFound | 404 | application/json |
apierrors.HTTPValidationError | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |