Files
Update File
Update a file.
Scopes: files:write
PATCH
/
v1
/
files
/
{id}
Go (SDK)
package main
import(
"context"
"os"
polargo "github.com/polarsource/polar-go"
"github.com/polarsource/polar-go/models/components"
"log"
"github.com/polarsource/polar-go/models/operations"
)
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 {
switch res.ResponseFilesUpdate.Type {
case operations.FilesUpdateResponseFilesUpdateTypeDownloadable:
// res.ResponseFilesUpdate.DownloadableFileRead is populated
case operations.FilesUpdateResponseFilesUpdateTypeProductMedia:
// res.ResponseFilesUpdate.ProductMediaFileRead is populated
case operations.FilesUpdateResponseFilesUpdateTypeOrganizationAvatar:
// res.ResponseFilesUpdate.OrganizationAvatarFileRead is populated
}
}
}from polar_sdk import Polar
with Polar(
access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:
res = polar.files.update(id="<value>", file_patch={})
# Handle response
print(res)import { Polar } from "@polar-sh/sdk";
const polar = new Polar({
accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});
async function run() {
const result = await polar.files.update({
id: "<value>",
filePatch: {},
});
console.log(result);
}
run();declare(strict_types=1);
require 'vendor/autoload.php';
use Polar;
use Polar\Models\Components;
$sdk = Polar\Polar::builder()
->setSecurity(
'<YOUR_BEARER_TOKEN_HERE>'
)
->build();
$filePatch = new Components\FilePatch();
$response = $sdk->files->update(
id: '<value>',
filePatch: $filePatch
);
if ($response->responseFilesUpdate !== null) {
// handle response
}curl --request PATCH \
--url https://api.polar.sh/v1/files/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"version": "<string>"
}
'const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: '<string>', version: '<string>'})
};
fetch('https://api.polar.sh/v1/files/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));HttpResponse<String> response = Unirest.patch("https://api.polar.sh/v1/files/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"version\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.polar.sh/v1/files/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"version\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"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",
"version": "<string>",
"service": "<string>",
"is_uploaded": true,
"created_at": "2023-11-07T05:31:56Z",
"size_readable": "<string>"
}{
"error": "<string>",
"detail": "<string>"
}{
"error": "<string>",
"detail": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Authorizations
You can generate an Organization Access Token from your organization's settings.
Path Parameters
The file ID.
Response
File updated.
- DownloadableFileRead
- ProductMediaFileRead
- OrganizationAvatarFileRead
File to be associated with the downloadables benefit.
The ID of the object.
Allowed value:
"downloadable"Was this page helpful?
⌘I
Go (SDK)
package main
import(
"context"
"os"
polargo "github.com/polarsource/polar-go"
"github.com/polarsource/polar-go/models/components"
"log"
"github.com/polarsource/polar-go/models/operations"
)
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 {
switch res.ResponseFilesUpdate.Type {
case operations.FilesUpdateResponseFilesUpdateTypeDownloadable:
// res.ResponseFilesUpdate.DownloadableFileRead is populated
case operations.FilesUpdateResponseFilesUpdateTypeProductMedia:
// res.ResponseFilesUpdate.ProductMediaFileRead is populated
case operations.FilesUpdateResponseFilesUpdateTypeOrganizationAvatar:
// res.ResponseFilesUpdate.OrganizationAvatarFileRead is populated
}
}
}from polar_sdk import Polar
with Polar(
access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:
res = polar.files.update(id="<value>", file_patch={})
# Handle response
print(res)import { Polar } from "@polar-sh/sdk";
const polar = new Polar({
accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});
async function run() {
const result = await polar.files.update({
id: "<value>",
filePatch: {},
});
console.log(result);
}
run();declare(strict_types=1);
require 'vendor/autoload.php';
use Polar;
use Polar\Models\Components;
$sdk = Polar\Polar::builder()
->setSecurity(
'<YOUR_BEARER_TOKEN_HERE>'
)
->build();
$filePatch = new Components\FilePatch();
$response = $sdk->files->update(
id: '<value>',
filePatch: $filePatch
);
if ($response->responseFilesUpdate !== null) {
// handle response
}curl --request PATCH \
--url https://api.polar.sh/v1/files/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"version": "<string>"
}
'const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: '<string>', version: '<string>'})
};
fetch('https://api.polar.sh/v1/files/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));HttpResponse<String> response = Unirest.patch("https://api.polar.sh/v1/files/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"version\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.polar.sh/v1/files/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"version\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"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",
"version": "<string>",
"service": "<string>",
"is_uploaded": true,
"created_at": "2023-11-07T05:31:56Z",
"size_readable": "<string>"
}{
"error": "<string>",
"detail": "<string>"
}{
"error": "<string>",
"detail": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}
