Skip to main content

Files

const files = sdk.asAdmin().Files()

Guides: Upload files, Private, protected and public files.

upload(folder, source)​

POST https://file-service.<domain>/{folder} (multipart form field file).

ParameterDescription
folderOne path segment, not URL-encoded. Prefix with public/ or protected/ to upload into that area, otherwise the file is private
source{ resolve: async () => ({ blob, filename }) }, created by a helper below

Resolves { status, result }. 201 with the file document, its url and image variants.

Throws sdk/fetch-failed on network errors. A non-JSON response raises a raw SyntaxError, and throwOnError is not honoured here.

Sources​

import { fromBase64, fromBlob, fromDisk, fromMultiPart } from '@scenid/cloud-sdk'
HelperSignature
fromDisk(filePath, filename?). MIME by extension, fallback application/octet-stream
fromBase64(filename, data, mimeType?). MIME inferred from the filename
fromBlob(filename, blob)
fromMultiPart(file, filename?) for multer (buffer, originalname, mimetype) or express-fileupload (data, name, mimetype)

Not available​

Download and delete are done with the file's URL and a file token, see the REST reference.