CAKE20

AI Web PaaS

public files

The storage function manages public files within the website root files.

Call from web page

The files/images/aaaa.jpg file is from the same website. It will be released to the address /files/images/aaaa.jpg.

In Cake20 View, you can use relative URLs starting with /files/. there is. When creating a URL in server code, use Object Storage Use storage.url() which also supports settings.

// app/pages/index.tsx
export default () => (
  <img src="/files/images/aaaa.jpg" alt="upload image" />
);

// server/api/image.get.ts
export default () => ({
  src: storage.url("images/aaaa.jpg")
});

Principles of use

  • Relative paths within files are displayed to the browser as the same /files/ URL.
  • Uploads and runtime generated files can only be saved to root files.
  • The website code uses storage rather than creating file paths directly.
  • Permanent write access for website processes is only in files and tmp. Use only for temporary files.
  • Uploaded files are saved without execution permission, and on Ubuntu-operated websites, You cannot run shells and external system commands.
  • A single upload request is subject to the upload/request capacity limit in website settings. Applies and the default value is 10MB.
  • Website-wide user files are subject to administrator default limits, which default to 100MB.
  • Passwords, authentication information and private documents are not stored in files.
  • User file capacity is managed within administrator-set limits, excluding build, backup, tmp, and .git.
  • File paths cannot contain values ​​or symbolic links outside the website root.
  • files are excluded from editor·MCP·build release·ZIP import and export.
  • The /files/ path only responds to website root files, not the current release.
  • Since files are not automatically backed up, necessary files are also stored in external storage.
await storage.put("avatars/1.webp", image);
const data = await storage.get("avatars/1.webp");
const files = await storage.list("avatars/");
const url = storage.url("avatars/1.webp"); // /files/avatars/1.webp
await storage.remove("avatars/1.webp");

STORAGE_ENDPOINT, STORAGE_BUCKET, STORAGE_ACCESS_KEY and Setting STORAGE_SECRET_KEY allows the same API to be used with S3-compatible Object Use Storage. If there is no setting, root files are used.