Create an Asset
webflow.createAsset(fileBlob)
Create a new asset on your Webflow site.
This method is specifically for creating new assets - if you need to update an existing asset, use the set asset file method instead. Be sure to review the limits and MIME types sections to ensure your files meet the requirements.
Adding assets to pages
To add an asset to a page:
- Create an asset
- Create an image element
- Use the
element.setAsset(asset)
method to set the asset
Syntax
Parameters
- fileBlob:
File
- Represents a valid File to be uploaded. Refer to the examples below for guidance on uploading an asset from a remote source and directly from a file picker.
Returns
Promise<Asset>
A Promise that resolves to the new Asset.
Example
Remote File
Direct Upload
Errors
If the method fails to create an asset, the method will return an error with the following cause and message.
Designer Ability
Limits
Uploaded assets must adhere to specific size limitations:
- Images must not exceed 4MB
- Documents are capped at 10MB
MIME Types
Refer to the accepted MIME types listed below for compatibility. Lottie files should be passed as application/json
MIME types.
MIME Types