Community Files
Create a File Upload
Create a file upload for a community. Community files can be used as a standard CDN and can be used in any object including Badges, Collections, and more.
POST
/
community
/
{id}
/
file
Create a file upload
curl --request POST \
--url https://api.openpage.fun/v1/community/{id}/file \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <api-key>' \
--data '
{
"name": "<string>"
}
'import requests
url = "https://api.openpage.fun/v1/community/{id}/file"
payload = { "name": "<string>" }
headers = {
"X-Api-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Api-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: '<string>'})
};
fetch('https://api.openpage.fun/v1/community/{id}/file', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.openpage.fun/v1/community/{id}/file",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Api-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.openpage.fun/v1/community/{id}/file"
payload := strings.NewReader("{\n \"name\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Api-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.openpage.fun/v1/community/{id}/file")
.header("X-Api-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.openpage.fun/v1/community/{id}/file")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Api-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"name": "testimage1-jpg",
"key": "fake-uuid-1234-5678-9012-3456/testimage1-jpg",
"mime": "image/jpeg",
"url": "https://img.openpage.fun/fake-uuid-1234-5678-9012-3456/testimage1-jpg?format=auto&size=600",
"communityId": "fake-uuid-1234-5678-9012-3456",
"thumbnail": null,
"uploadedAt": null,
"id": "fake-uuid-1234-5678-9012-3456",
"createdAt": "2025-03-05T21:27:37.411Z",
"upload": {
"method": "POST",
"url": "https://s3.us-west-2.amazonaws.com/other-page-files",
"body": {
"success_action_status": "201",
"key": "fake-uuid-1234-5678-9012-3456/testimage1-jpg",
"Content-Type": "image/jpeg",
"x-amz-meta-account": "fake-uuid-1234-5678-9012-3456",
"bucket": "other-page-files",
"X-Amz-Algorithm": "AWS4-HMAC-SHA256",
"X-Amz-Credential": "ADEFADEFADEF/20250305/us-west-2/s3/aws4_request",
"X-Amz-Date": "20250305T212737Z",
"X-Amz-Security-Token": "ALongSecurityStringToken=",
"Policy": "eyJlExamplePolicyJwt...",
"X-Amz-Signature": "02342352578923525525253251212745634...",
"x-amz-meta-file": "fake-uuid-1234-5678-9012-3456",
"x-amz-meta-community": "fake-uuid-1234-5678-9012-3456"
}
}
}
{
"name": "testimage1-jpg",
"key": "fake-uuid-1234-5678-9012-3456/testimage1-jpg",
"mime": "image/jpeg",
"url": "https://img.openpage.fun/fake-uuid-1234-5678-9012-3456/testimage1-jpg?format=auto&size=600",
"communityId": "fake-uuid-1234-5678-9012-3456",
"thumbnail": null,
"uploadedAt": null,
"id": "fake-uuid-1234-5678-9012-3456",
"createdAt": "2025-03-05T21:27:37.411Z",
"upload": {
"method": "POST",
"url": "https://s3.us-west-2.amazonaws.com/other-page-files",
"body": {
"success_action_status": "201",
"key": "fake-uuid-1234-5678-9012-3456/testimage1-jpg",
"Content-Type": "image/jpeg",
"x-amz-meta-account": "fake-uuid-1234-5678-9012-3456",
"bucket": "other-page-files",
"X-Amz-Algorithm": "AWS4-HMAC-SHA256",
"X-Amz-Credential": "ADEFADEFADEF/20250305/us-west-2/s3/aws4_request",
"X-Amz-Date": "20250305T212737Z",
"X-Amz-Security-Token": "ALongSecurityStringToken=",
"Policy": "eyJlExamplePolicyJwt...",
"X-Amz-Signature": "02342352578923525525253251212745634...",
"x-amz-meta-file": "fake-uuid-1234-5678-9012-3456",
"x-amz-meta-community": "fake-uuid-1234-5678-9012-3456"
}
}
}
Uploading Your File to The CDN
Once you’ve created an OpenPage file upload request, you will need to upload the file to make use of it by executing aPOST request to the file upload endpoint with a body containing the upload.body object.
CURL Request Example
curl --location 'https://s3.us-west-2.amazonaws.com/other-page-files' \
--form 'key="fake-uuid-1234-5678-9012-3456/testimage1-jpg"' \
--form 'success_action_status="201"' \
--form 'Content-Type="image/jpeg"' \
--form 'x-amz-meta-account="fake-uuid-1234-5678-9012-3456"' \
--form 'bucket="other-page-files-dev"' \
--form 'X-Amz-Algorithm="AWS4-HMAC-SHA256"' \
--form 'X-Amz-Credential="ADEFADEFADEF/20250305/us-west-2/s3/aws4_request"' \
--form 'X-Amz-Date="20250305T212737Z"' \
--form 'Policy="eyJlExamplePolicyJwt..."' \
--form 'X-Amz-Signature="02342352578923525525253251212745634..."' \
--form 'x-amz-meta-file="fake-uuid-1234-5678-9012-3456"' \
--form 'x-amz-meta-community="fake-uuid-1234-5678-9012-3456"' \
--form 'file=@"/Path/To/Your/File/TestFile.png"'
Image CDN
Image files can make use of the OpenPage image CDNhttps://img.openpage.fun/{your-file-key}?format={format}&size={size} to auto format and resize as needed.
Below is an example of how to return your image with a max size of 100px and as a png.
https://img.openpage.fun/fake-uuid-1234-5678-9012-3456/testimage1-jpg?format=png&size=100⌘I
Create a file upload
curl --request POST \
--url https://api.openpage.fun/v1/community/{id}/file \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <api-key>' \
--data '
{
"name": "<string>"
}
'import requests
url = "https://api.openpage.fun/v1/community/{id}/file"
payload = { "name": "<string>" }
headers = {
"X-Api-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Api-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: '<string>'})
};
fetch('https://api.openpage.fun/v1/community/{id}/file', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.openpage.fun/v1/community/{id}/file",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Api-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.openpage.fun/v1/community/{id}/file"
payload := strings.NewReader("{\n \"name\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Api-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.openpage.fun/v1/community/{id}/file")
.header("X-Api-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.openpage.fun/v1/community/{id}/file")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Api-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"name": "testimage1-jpg",
"key": "fake-uuid-1234-5678-9012-3456/testimage1-jpg",
"mime": "image/jpeg",
"url": "https://img.openpage.fun/fake-uuid-1234-5678-9012-3456/testimage1-jpg?format=auto&size=600",
"communityId": "fake-uuid-1234-5678-9012-3456",
"thumbnail": null,
"uploadedAt": null,
"id": "fake-uuid-1234-5678-9012-3456",
"createdAt": "2025-03-05T21:27:37.411Z",
"upload": {
"method": "POST",
"url": "https://s3.us-west-2.amazonaws.com/other-page-files",
"body": {
"success_action_status": "201",
"key": "fake-uuid-1234-5678-9012-3456/testimage1-jpg",
"Content-Type": "image/jpeg",
"x-amz-meta-account": "fake-uuid-1234-5678-9012-3456",
"bucket": "other-page-files",
"X-Amz-Algorithm": "AWS4-HMAC-SHA256",
"X-Amz-Credential": "ADEFADEFADEF/20250305/us-west-2/s3/aws4_request",
"X-Amz-Date": "20250305T212737Z",
"X-Amz-Security-Token": "ALongSecurityStringToken=",
"Policy": "eyJlExamplePolicyJwt...",
"X-Amz-Signature": "02342352578923525525253251212745634...",
"x-amz-meta-file": "fake-uuid-1234-5678-9012-3456",
"x-amz-meta-community": "fake-uuid-1234-5678-9012-3456"
}
}
}
