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{
            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

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

Schema to create a file to be associated with the downloadables benefit.

name
string
required
mime_type
string
required
size
integer
required
upload
object
required
service
string
required
Allowed value: "downloadable"
organization_id
string | null

The organization ID.

checksum_sha256_base64
string | null
version
string | null

Response

201
application/json
File created.
id
string
required

The ID of the object.

organization_id
string
required
name
string
required
path
string
required
mime_type
string
required
size
integer
required
storage_version
string | null
required
checksum_etag
string | null
required
checksum_sha256_base64
string | null
required
checksum_sha256_hex
string | null
required
last_modified_at
string | null
required
upload
object
required
version
string | null
required
service
enum<string>
required
Available options:
downloadable,
product_media,
organization_avatar
size_readable
string
required
is_uploaded
boolean
default:
false

Was this page helpful?