This method creates a new asset upload task and adds it to the upload queue.
It returns a asset reference, and a function called whenUploaded()
that can
be used to await the upload task completion.
Parameters
Options for uploading an asset to the user's private media library.
Options for uploading an image asset to the user's private media library.
A disclosure identifying if the app generated this image using AI
Helps users make informed decisions about the content they interact with. See AiDisclosure for the full definition.
App Generated
'app_generated' indicates when the app creates or significantly alters an asset using AI. Includes when the app requests a third-party service to take similar action on an image using AI.
Required for the following cases (this list is not exhaustive):
None
'none' indicates when the app doesn't create or significantly alter an asset using AI, or as a part of a request to third-party hosted content.
Required for the following cases (this list is not exhaustive):
The available options include:
"app_generated"
"none"
The MIME type of the image file.
The available options include:
"image/jpeg"
"image/heic"
"image/png"
"image/svg+xml"
"image/webp"
"image/tiff"
The URL of a thumbnail image to display while the image is queued for upload. This can be an external URL or a data URL.
Requirements for external URLs:
- Must use HTTPS
- Must support Cross-Origin Resource Sharing
- Must be a PNG, JPEG, or SVG file
- Maximum length: 4096 characters
Requirements for data URLs:
- Must include
;base64
for base64-encoded data - Maximum size: 10MB (10 × 1024 × 1024 characters)
The type of asset.
This must be "image"
.
The URL of the image file to upload. This can be an external URL or a data URL.
Requirements for external URLs:
- Must use HTTPS
- Must return a
200
status code Content-Type
must match the file's MIME type- Must be publicly accessible (i.e. not a localhost URL)
- Must not redirect
- Must not contain an IP address
- Maximum length: 4096 characters
- Must not contain whitespace
- Must not contain these characters:
>
,<
,{
,}
,^
, backticks - Maximum file size: 50MB
Requirements for data URLs:
- Must include
;base64
for base64-encoded data - Maximum size: 10MB (10 × 1024 × 1024 characters)
Requirements for SVGs:
- Disallowed elements:
a
altglyph
altglyphdef
altglyphitem
animate
animatemotion
animatetransform
cursor
discard
font
font-face
font-face-format
font-face-name
font-face-src
font-face-uri
foreignobject
glyph
glyphref
missing-glyph
mpath
script
set
switch
tref
- Disallowed attributes:
crossorigin
lang
media
onload
ping
referrerpolicy
rel
rendering-intent
requiredextensions
requiredfeatures
systemlanguage
tabindex
transform-origin
unicode
vector-effect
- The
href
attribute of animage
element only supports data URLs for PNG and JPEG images. - The URL in the
href
attribute must not point to a location outside of the SVG. - The
style
attribute must not use themix-blend-mode
property.
The ref of the original asset from which this new asset was derived.
For example, if an app applies an effect to an image, parentRef
should contain the ref of the original image.
A height, in pixels.
A width, in pixels.
Returns
An asset that's queued for upload to the user's private media library. This is a Promise
that resolves with the following object: