Content.upload
luastra/contentContent.upload(image: Image, intent: string): number
Streams a selected preview to a server-created opaque upload intent through the same-origin host route, outside the bounded Luau RPC envelope and without exposing provider authorization.
Before you use it
Add luastra/content to this module's dependencies in luastra.json, then import it with require("luastra/content"). Declare content.pick for browser selection and content.upload for transfer. Upload requires a server-created intent from an authenticated declared backend function. Application code must never construct a provider URL, file path, data URL, blob URL, bucket path, or upload handle.
How it fits
Image construction and decoders are synchronous. Selection, release, upload, and cancellation return request IDs and complete through application/app resolve; progress enters application/app handle as content_progress.
When to use it
Use Content.upload only after an authenticated declared backend function returns an upload: handle bound to the selected type, bytes, dimensions, principal, purpose, and short expiry.
Parameters
| Parameter | Type / values | Description |
|---|---|---|
| image | Image | Selected preview image returned by Content.pickImage. |
| intent | string | Opaque upload: handle created by an authenticated backend function. |
Returns
number — the exact number value declared by the SDK contract.
What happens next
A bounded image lifecycle that keeps local files and provider credentials outside Luau while reusing UI.Image.
Failures and fixes
Cancellation, malformed or expired handles, unsupported media types, excessive bytes or dimensions, offline transfer, authorization denial, and decode failure remain explicit branches. Release previews, request fresh display grants after UI.Image.onError, and never persist or log upload/content handles.
Availability
Private source foundation after 0.5.0-alpha; browser PNG/JPEG selection and upload are automated, while camera and native picker certification remain later evidence gates.
Focused example
local uploadRequestId = Content.upload(selected, intent.handle)