Files
Store images, videos and documents in a datastore from your app, point to them from your records, and show them again.
What it is
Your app can store a file in a datastore, such as an ad’s image or video, a contract, or a brand guide. Manta keeps
the file and adds a node for it to the knowledge graph, so your records can point to it. This page is for files your app sends one at a time. To load data files in bulk from a script, use the
manta-upload CLI.
Who can upload
An upload runs three GraphQL mutations: initiateUpload, completeUpload and, when something fails, abortUpload.
A custom app can call them with:
- its machine token, from your server. This is the usual way.
- the token of a person signed in with a Manta account.
A custom app user’s token and a visitor token only read, so they cannot upload or delete. An upload does not need the
SPARQL writes permission. It reaches only the datastores the app is limited to,
so an app picked for acme-crm and acme-crm-test can upload to those two and gets a 403 for any other.
Upload from your server
- Call
initiateUploadwith the file name and its size in bytes. It returns anuploadId, astorageKey, and one signed URL for each 8 MiB part of the file. The URLs are valid for six hours. PUTeach part of the file to its URL, and keep theETagheader of each response.- Call
completeUploadwith the parts and their ETags. It returns the file’sfileIriandmediaType.
If a step fails, call abortUpload so the parts that arrived are deleted.
const mantaUrl = "https://app.hiremanta.com";
const datastore = "acme-crm";
const partSize = 8 * 1024 * 1024;
type UploadedFile = { fileIri: string; mediaType: string; storageKey: string };
async function graphql<T>(token: string, query: string, variables: object): Promise<T> {
const response = await fetch(`${mantaUrl}/graphql`, {
method: "POST",
headers: {
Authorization: `Bearer ${token}`,
"x-manta-datastore": datastore,
"Content-Type": "application/json",
},
body: JSON.stringify({ query, variables }),
});
const { data, errors } = await response.json();
if (errors?.length) throw new Error(errors[0].message);
return data;
}
export async function uploadFile(token: string, fileName: string, bytes: Uint8Array): Promise<UploadedFile> {
const { initiateUpload } = await graphql<{
initiateUpload: { uploadId: string; storageKey: string; partUrls: { partNumber: number; url: string }[] };
}>(
token,
`
mutation ($input: InitiateUploadInput!) {
initiateUpload(input: $input) {
uploadId
storageKey
partUrls {
partNumber
url
}
}
}
`,
{ input: { fileName, byteSize: bytes.byteLength } },
);
const { uploadId, storageKey, partUrls } = initiateUpload;
try {
const parts = await Promise.all(
partUrls.map(async ({ partNumber, url }) => {
const start = (partNumber - 1) * partSize;
const response = await fetch(url, { method: "PUT", body: bytes.subarray(start, start + partSize) });
if (!response.ok) throw new Error(`Part ${partNumber} failed with ${response.status}`);
return { partNumber, etag: response.headers.get("ETag") };
}),
);
const { completeUpload } = await graphql<{ completeUpload: { fileIri: string; mediaType: string } }>(
token,
`
mutation ($input: CompleteUploadInput!) {
completeUpload(input: $input) {
fileIri
mediaType
}
}
`,
{ input: { uploadId, storageKey, fileName, parts, facts: { byteSize: bytes.byteLength } } },
);
return { ...completeUpload, storageKey };
} catch (error) {
await graphql(
token,
`
mutation ($input: AbortUploadInput!) {
abortUpload(input: $input) {
ok
}
}
`,
{
input: { uploadId, storageKey },
},
);
throw error;
}
}
The parts must be 8 MiB each, apart from the last one: Manta counts the parts from that size. facts can also
carry the file’s sha256 (hex), and an image’s width and height, which Manta records on the file’s node.
Upload from the browser
A page signed in with a Manta account can upload the same way. FileDropzone from @manta-eu/react/file-dropzone
hands you the dropped File objects and turns away files over the size limit, and uploadFile from
@manta-eu/react/lib/upload-client runs the three steps with the generated mutations from @manta-eu/client.
A browser on your own site cannot PUT to the signed URLs directly. It sends each part to
/d/<datastore>/agents/uploads/part?url=<signed URL> on your Manta deployment, with the bearer token, and Manta
passes it on. uploadFile does this when you give it a relay.
For a custom app whose users have no Manta account, upload from your server with the machine token instead.
Point to a file from your records
Each upload gets a new fileIri, the IRI completeUpload returns. It names a node like this one:
<s3://example-bucket/hiremanta-com/acme-crm/files/sell-your-clothes-0196f3c2-7b1e-7c4a-9d2f-5e8a1b3c4d6e.jpg>
a nfo:FileDataObject ;
nfo:fileName "sell-your-clothes.jpg" ;
nmo:contentMimeType "image/jpeg" ;
nfo:fileSize 284113 ;
nfo:width 1080 ;
nfo:height 1080 ;
prov:generatedAtTime "2026-11-17T09:12:44Z"^^xsd:dateTime ;
prov:wasAttributedTo :User_… .
Point to the file from your own record with a property of your vocabulary, and keep the storageKey next to it. You
need the key to show or delete the file, and the file’s node does not carry it:
<https://acme.example/id/ad/vinted-sell-your-clothes> a acme:Ad ;
acme:headline "Sell your clothes in minutes" ;
acme:creative <s3://example-bucket/hiremanta-com/acme-crm/files/sell-your-clothes-0196f3c2-7b1e-7c4a-9d2f-5e8a1b3c4d6e.jpg> ;
acme:creativeStorageKey "hiremanta-com/acme-crm/files/sell-your-clothes-0196f3c2-7b1e-7c4a-9d2f-5e8a1b3c4d6e.jpg" .
Treat fileIri as an opaque name. Its shape is not a contract, so read the storage key from your own record, not out
of the IRI.
Show a file
GET /d/<datastore>/agents/uploads/file?key=<storageKey> with a token that reaches the datastore answers with a
redirect to a signed download URL. The URL is valid for 15 minutes, so ask for a new one each time you show the file
rather than storing it. Images (PNG, JPEG, GIF, WebP, AVIF), MP4 and WebM video, and PDFs open in the browser. Other
types download. A key from another datastore gets a 403.
An <img> or <video> tag cannot send a bearer token, so let your server ask for the redirect and hand the signed
URL to the page:
export async function fileUrl(token: string, storageKey: string): Promise<string> {
const url = new URL(`/d/${datastore}/agents/uploads/file`, mantaUrl);
url.searchParams.set("key", storageKey);
const response = await fetch(url, { headers: { Authorization: `Bearer ${token}` }, redirect: "manual" });
const location = response.headers.get("Location");
if (response.status !== 302 || location === null) throw new Error(`No file URL: ${response.status}`);
return location;
}
Delete a file
The deleteUpload mutation deletes the file and its node in the knowledge graph, and Manta then removes any triples
the file loaded. It takes the storageKey:
mutation ($input: DeleteUploadInput!) {
deleteUpload(input: $input) {
ok
}
}
Through a custom app, it deletes only a file the same caller uploaded through the same app: the app’s machine token deletes what the machine token uploaded, and a person signed in with a Manta account deletes what they uploaded through that app. Manta records the uploader and the app on the stored file when the upload starts, where no SPARQL write can change them. Any other file answers “A custom app may delete only the files it uploaded” and stays: one a person uploaded in Manta, one another app uploaded, and one uploaded before Manta recorded who made it. A custom app user’s token and a visitor token cannot delete at all. Remove your record’s link to the file in the same step.
Limits and ingest
- A file can be up to 5 GiB, and its name up to 255 bytes. A datastore has no storage quota.
- Manta reads only CSV, Parquet, Turtle and N-Triples files into the knowledge graph, as described in Upload. It stores any other file, such as an image, a video or a PDF, and adds only the file’s node.
- Each upload is a new file with a new
fileIri, even when the name and the bytes are the same.
FAQ
Can my app use the same upload as the Manta app? Yes. It is the same initiateUpload and completeUpload, with
the app’s machine token and only the datastores the app is limited to. See Who can upload.
How do I get the file back to show it? Ask /agents/uploads/file for a signed URL, valid for 15 minutes, each
time you show it. See Show a file.
Can I delete a file when my app throws a record away? Yes, a file your app uploaded. Call deleteUpload with the
storage key and the app’s machine token. See Delete a file.
What does a file’s ID look like, and can my records point to it? It is the fileIri that completeUpload
returns, and yes. Treat it as an opaque name, and keep the storage key on your record as well. See Point to a file from your records.
Does an image or a video count against a limit, or get read into the graph? It can be up to 5 GiB, there is no quota, and Manta only stores it. See Limits and ingest.