GhaylStackDocumentationv1.0.2
العربيةWebsite
Platform modules

Platform modules

Files, uploads and attachment policies

Complete the signed upload flow, enforce owner-specific access and troubleshoot storage failures.

Follow all three upload steps

Files stores file metadata while the configured storage provider holds the bytes. Its API starts with /api/v1/files. A successful upload needs three distinct steps:

  1. Request a URL with POST /upload-url, supplying owner type and optional owner ID, filename, content type, declared size, visibility and category.
  2. Send the bytes to the returned upload URL using its returned RequiredHeaders. The signature's content type is derived from the validated file extension; a client's arbitrary declaration is not trusted.
  3. Call POST /{id}/finalize. The handler reads the stored object's metadata, verifies size and content type, invokes the scanner and records actual storage usage.

Requesting a URL alone leaves a PendingUpload record. The finalize operation is essential; do not show the attachment as completed simply because the PUT request succeeded.

Choose category and access policy

The checked-in API configuration defines these category limits:

Category Allowed examples Maximum size
Image JPG, JPEG, PNG, WebP, GIF, ICO 10 MiB
Document PDF, DOCX, XLSX, PPTX, TXT, CSV 25 MiB
Archive ZIP 50 MiB

An owner type must have a registered IFileAccessPolicy. The built-in MyFiles and User policy checks the uploader for private reads and deletion. Product, chat, ticket and workflow attachments use their owning module's policy. Some owners require private files even if the caller requests public visibility.

Read and share a file

Use GET /{id} for metadata and GET /{id}/url for a signed download URL. The download handler resolves the owner policy and deliberately returns not-found for an unauthorized read. An existing database row therefore does not guarantee the caller can retrieve it.

The API configuration sets upload URLs to 15 minutes and download URLs to 60 minutes. These values override the class defaults. Request a new URL when a link expires. Public visibility affects object-storage exposure; choose it only for content intended for public access, such as approved product images.

Retention, quotas and scanning

The module prechecks storage quota before issuing an upload URL and records actual bytes on finalization. Orphan cleanup is scheduled hourly, and deleted-file cleanup at 03:30 UTC. The checked-in retention values are 60 minutes for unfinished uploads and 30 days for soft-deleted files.

The supplied scanner is NoOpFileScanner, which returns Clean without inspecting file contents. Applications that require malware inspection must provide an IFileScanner implementation and test its failure behavior. A successful finalize response should not be described as a malware scan certificate.

Verify and troubleshoot

Upload a small allowed document, finalize it and download it as its owner. Then try a user without the owning record's access. Test an expired upload URL, a disallowed extension and a declared size mismatch.

If the browser PUT fails, inspect the returned headers, storage endpoint reachability and CORS. If finalize returns 409, check whether the object was received or was already finalized. A 507 quota rejection requires reviewing usage or limits. For owner-policy rejection, inspect permissions on the ticket, workflow or other owning record before relaxing file visibility.

Implementation references

View MarkdownBack to top

Search documentation

Use ↑ ↓ to move, Enter to open and Esc to close.