File Storage
Storage Overview
RavenSaaS supports uploading files to AWS S3 compatible file storage systems, such as AWS S3 / Cloudflare R2 / Tencent Cloud COS, etc.
S3 Compatible
Supports AWS S3 compatible storage systems, including Cloudflare R2, Tencent Cloud COS, etc.
Multiple Upload Methods
Supports multiple upload methods including AI images, local files, remote files, etc.
Easy to Use
Provides simple API interfaces that can be easily integrated into your application.
Configure Cloud Storage
Choose your cloud storage platform, create storage buckets, set access keys and access domains. Then fill in the relevant parameters in the project configuration file:
Environment Variable Configuration
.env.production
1STORAGE_ENDPOINT=""
2STORAGE_REGION=""
3STORAGE_ACCESS_KEY=""
4STORAGE_SECRET_KEY=""
5STORAGE_BUCKET=""
6STORAGE_DOMAIN=""
File Upload
Upload AI Images to Cloud Storage
Upload images generated by aisdk (returned base64 data) to cloud storage.
app/api/demo/gen-image/route.ts
1import { uploadFile } from "@/lib/storage";
2
3const filename = `image_${new Date().getTime()}.png`;
4const key =`ravensaas/${filename}`;
5const body = Buffer.from(image.base64, "base64");
6
7try {
8 const url = await uploadFile(body, key, "image/png", "inline");
9
10 console.log("upload file success:", url);
11} catch (err) {
12 console.log("upload file failed:", err);
13}
注意:The body parameter received by uploadFile is of Buffer type. You can pass a file Buffer downloaded from a URL or a Buffer read from a local file.
Reference
Last updated on January 5, 2025