Files
Create File
Core API
- Checkout
- Checkout Links
- Custom Checkout Fields
- Customers
- Subscriptions
- Orders
- Discounts
- Refunds
- Products
- Events
- Meters
- Benefits
- Customer Meters
- License Keys
- Files
- Organizations
- Metrics
Customer Portal API
- GETGet Customer
- GETGet Organization
- Sessions
- Subscriptions
- Orders
- License Keys
- File Downloads
Webhook Events
- Customer Events
- Billing Events
- Organization Events
OAuth 2.0 API
- Connect
- Clients
Files
Create File
Create a file.
Scopes: files:write
POST
/
v1
/
files
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.CreateFileCreateProductMedia(
components.ProductMediaFileCreate{
OrganizationID: polargo.String("1dbfc517-0bbf-4301-9ba8-555ca42b9737"),
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
}
}
{
"id": "<string>",
"organization_id": "<string>",
"name": "<string>",
"path": "<string>",
"mime_type": "<string>",
"size": 123,
"storage_version": "<string>",
"checksum_etag": "<string>",
"checksum_sha256_base64": "<string>",
"checksum_sha256_hex": "<string>",
"last_modified_at": "2023-11-07T05:31:56Z",
"upload": {
"id": "<string>",
"path": "<string>",
"parts": [
{
"number": 123,
"chunk_start": 123,
"chunk_end": 123,
"checksum_sha256_base64": "<string>",
"url": "<string>",
"expires_at": "2023-11-07T05:31:56Z",
"headers": {}
}
]
},
"version": "<string>",
"is_uploaded": false,
"service": "downloadable",
"size_readable": "<string>"
}
Authorizations
You can generate an Organization Access Token from your organization's settings.
Body
application/json
Schema to create a file to be associated with the downloadables benefit.
Schema to create a file to be associated with the downloadables benefit.
Schema to create a file to be used as a product media file.
Schema to create a file to be used as an organization avatar.
Response
201
application/json
File created.
The response is of type object
.
Was this page helpful?
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.CreateFileCreateProductMedia(
components.ProductMediaFileCreate{
OrganizationID: polargo.String("1dbfc517-0bbf-4301-9ba8-555ca42b9737"),
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
}
}
{
"id": "<string>",
"organization_id": "<string>",
"name": "<string>",
"path": "<string>",
"mime_type": "<string>",
"size": 123,
"storage_version": "<string>",
"checksum_etag": "<string>",
"checksum_sha256_base64": "<string>",
"checksum_sha256_hex": "<string>",
"last_modified_at": "2023-11-07T05:31:56Z",
"upload": {
"id": "<string>",
"path": "<string>",
"parts": [
{
"number": 123,
"chunk_start": 123,
"chunk_end": 123,
"checksum_sha256_base64": "<string>",
"url": "<string>",
"expires_at": "2023-11-07T05:31:56Z",
"headers": {}
}
]
},
"version": "<string>",
"is_uploaded": false,
"service": "downloadable",
"size_readable": "<string>"
}