mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-10-30 08:37:56 +09:00
## Summary - Add CLI project import support from synced `.webstudio/data.json` into another project via a destination share link. - Move project bundle import/export contract into `@webstudio-is/protocol`, including bundle versioning, staged upload constants, schema validation, and fixture coverage. - Upload project bundle data through staged TUS upload before calling the import RPC to avoid request body limits. - Upload referenced assets as binary files through the existing asset upload route before importing asset rows. - Add `--skip-assets` and `--ignore-version-check` import options. - Add retry handling for transient missing imported asset files by re-uploading only the reported missing assets. - Share missing-asset import error formatting/parsing through protocol to avoid duplicated string contracts. - Preserve browser asset upload behavior while adding API upload support. - Normalize schema naming across the branch to lower-case names without `Schema` suffix.
36 lines
981 B
TypeScript
36 lines
981 B
TypeScript
import * as path from "node:path";
|
|
import { maxSize } from "@webstudio-is/asset-uploader";
|
|
import {
|
|
createFsClient,
|
|
createS3Client,
|
|
} from "@webstudio-is/asset-uploader/index.server";
|
|
import env from "~/env/env.server";
|
|
|
|
export const fileUploadPath = "public/cgi/asset";
|
|
|
|
export const createAssetClient = () => {
|
|
const maxUploadSize = maxSize.parse(env.MAX_UPLOAD_SIZE);
|
|
if (
|
|
env.S3_ENDPOINT !== undefined &&
|
|
env.S3_REGION !== undefined &&
|
|
env.S3_ACCESS_KEY_ID !== undefined &&
|
|
env.S3_SECRET_ACCESS_KEY !== undefined &&
|
|
env.S3_BUCKET !== undefined
|
|
) {
|
|
return createS3Client({
|
|
endpoint: env.S3_ENDPOINT,
|
|
region: env.S3_REGION,
|
|
accessKeyId: env.S3_ACCESS_KEY_ID,
|
|
secretAccessKey: env.S3_SECRET_ACCESS_KEY,
|
|
bucket: env.S3_BUCKET,
|
|
acl: env.S3_ACL,
|
|
maxUploadSize,
|
|
});
|
|
} else {
|
|
return createFsClient({
|
|
maxUploadSize,
|
|
fileDirectory: path.join(process.cwd(), fileUploadPath),
|
|
});
|
|
}
|
|
};
|