The DatoCMS clients provide numerous methods for users to upload resources. The method you choose can be influenced by different aspects like the platform you're using (such as Node.js or a browser) and where the resource is coming from — like a local file, a remote URL, or a File
or Blob
obtained from <input type="file" />
elements.
This example shows how to add assets to the Media Area by uploading a local file.
Here's a demonstration of how you can uploading an asset from a remote location, accessible through a URL.
Regardless of the upload method, you can always get information about the operation's progress by listening to the events that hit the onProgress
callback.
Each available method yields a cancellable promise, granting the ability to halt a currently running upload operation.
It is possible to cancel an upload operation by calling the .cancel()
method on the promise returned by one of the upload creation methods (createFromUrl()
, createFromLocalFile()
in NodeJS, createFromFileOrBlob()
in browser):
RFC 4122 UUID of upload expressed in URL-safe base64 format
"q0VNpiNQSkG6z0lif_O1zg"
Upload path
"/45/1496845848-digital-cats.jpg"
Copyright
"2020 DatoCMS"
Author
"Mark Smith"
Notes
"Nyan the cat"
For each of the project's locales, the default metadata to apply if nothing is specified at record's level.
{
en: {
title: "this is the default title",
alt: "this is the default alternate text",
custom_data: { foo: "bar" },
focal_point: { x: 0.5, y: 0.5 },
},
}
Tags
["cats"]
Upload collection to which the asset belongs
Returns a resource object of type upload