Headless TypeScript SDK for uploading an image, video, or generic file to Shopify Files.
stagedUploadsCreate
→ upload binary directly to Shopify staged storage
→ fileCreate
→ poll fileStatus
→ READY | FAILED
The SDK never receives or stores Shopify credentials. Your app supplies an already-authenticated GraphQL executor.
npm install @weaverse/shopify-file-uploadimport {createShopifyFileUpload} from '@weaverse/shopify-file-upload/server'
const files = createShopifyFileUpload({
shopify: {
apiVersion: '2026-07',
graphql: async (query, variables) => {
// Use your app-owned authenticated Shopify Admin client here.
const response = await admin.graphql(query, {variables})
return response.json()
},
},
})
const uploaded = await files.upload({
source: new Blob([bytes], {type: 'image/png'}),
filename: 'hero.png',
})
console.log(uploaded.status) // ready | failedThe low-level server methods are also public:
const [prepared] = await files.prepare([
{filename: 'hero.png', mimeType: 'image/png', size: fileSize},
])
await files.uploadBinary(prepared, blob)
const registered = await files.register({
clientId: prepared.clientId,
resourceUrl: prepared.target.resourceUrl,
filename: prepared.input.filename,
mimeType: prepared.input.mimeType,
type: prepared.input.type,
})
const settled = await files.waitUntilReady([registered.id])The browser asks your backend for Shopify GraphQL operations, but sends the binary directly to Shopify staged storage.
import {uploadShopifyFile} from '@weaverse/shopify-file-upload/browser'
const uploaded = await uploadShopifyFile(file, {
transport: {
prepare: (input, {signal}) =>
fetch('/api/shopify-files/prepare', {
method: 'POST',
headers: {'content-type': 'application/json'},
body: JSON.stringify(input),
signal,
}).then((response) => response.json()),
register: (input) =>
fetch('/api/shopify-files/register', {
method: 'POST',
headers: {'content-type': 'application/json'},
body: JSON.stringify(input),
}).then((response) => response.json()),
getStatus: (fileId, {signal}) =>
fetch(`/api/shopify-files/status?id=${encodeURIComponent(fileId)}`, {signal}).then(
(response) => response.json(),
),
},
onProgress: ({percent}) => console.log(percent),
})Backend handlers can map directly to:
files.prepare([input]).then(([prepared]) => prepared)
files.register(input)
files.getStatuses([fileId]).then(([result]) => result)fileCreateis asynchronous; the SDK waits forREADYorFAILEDby default.- Browser Admin credentials are never supported.
- Binary data does not go through Admin GraphQL.
- No automatic retry occurs after
fileCreate. A lost registration response is reported asREGISTRATION_AMBIGUOUSand is non-retryable to prevent duplicates. AbortSignalcancels preparation and binary upload. After registration starts, cancellation only stops local status waiting; the Shopify file may already exist.- SVG and WebM are treated as generic
FILEuploads in this version.
@weaverse/shopify-file-upload shared types, constants, errors
@weaverse/shopify-file-upload/server Shopify GraphQL orchestration
@weaverse/shopify-file-upload/browser one-file browser upload
MIT © Weaverse