Web-Based Direct Upload (Presigned URL)
To upload files to OSS from the frontend, use a presigned URL to enable secure direct uploads. The server generates a presigned URL with specific permissions (e.g., PutObject
), and the client uploads the file directly to OSS using the signed URL.
Steps:
- Create a Bucket
Go to Buckets, click Create Bucket, specify a Bucket Name (e.g.,
static-web-example
) and click Create Bucket. - Configure CORS
Configure Cross-Origin Resource Sharing (CORS) rules for the bucket using the
PutBucketCors
API. - Generate a Presigned URL
Use AWS S3 SDK on the server to generate a presigned URL with
PutObject
permission for secure uploads. - Upload via Web Build an HTML form that submits the file directly to OSS using the presigned URL.