Small-file upload encoding
Small-file upload encoding
Public contract
POST /v1/creative/assets accepts JSON; binary data is a base64 string, not multipart. Calling the endpoint requires its permitted user/org identity, creative:write and applicable project parameters; see API Reference. The encoding helper performs no network request and does not create projects.
The helper accepts in-memory bytes strictly smaller than 4 MiB and rejects the boundary or larger inputs. Empty, NUL and non-UTF8 bytes remain binary. These examples print AP8=. Install packages as shown in quickstart.
TypeScript
import { encodeUploadData } from "@appforges/sdk/runtime/upload";
console.log(encodeUploadData(new Uint8Array([0, 255])));Python
from appforges import encode_upload_data
print(encode_upload_data(bytes([0, 255])))Go
package main
import (
"fmt"
"log"
"github.com/appforges/appforges-sdk-go/runtime"
)
func main() {
data, err := runtime.EncodeUploadData([]byte{0, 255})
if err != nil { log.Fatal(err) }
fmt.Println(data)
}JSON payload
Place the encoded result in the generated UploadAsset request's data property and supply the other fields from API Reference. This partial JSON only illustrates the encoding field:
{"data": "AP8="}Public REST currently has no large-file presigned upload/confirmation endpoint. Re-signing an asset access URL does not produce an upload URL. Confirm an available service contract for larger files; do not reuse this example beyond its size limit.
See errors and retries for write safety and X-Idempotency-Key.