DataTransferItem

The DataTransferItem object represents one drag data item. During a drag operation, each DragEvent has a dataTransfer property which contains a list of drag data items. Each item in the list is a DataTransferItem object.

MDN Reference

Properties

Link copied to clipboard
open external val kind: String

The kind read-only property of the DataTransferItem interface returns the kind–a string or a file–of the object representing the drag data item.

Link copied to clipboard
open external val type: String

The type read-only property of the DataTransferItem interface returns the type (format) of the object representing the drag data item. The type is a Unicode string generally given by a MIME type, although a MIME type is not required.

Functions

Link copied to clipboard
open external fun getAsFile(): File?

The getAsFile() method of the DataTransferItem interface returns the drag data item's File object if the item is a file. If the item is not a file, this method returns null.

Link copied to clipboard
open external fun getAsString(callback: FunctionStringCallback?)

The getAsString() method of the DataTransferItem interface invokes the given callback with the drag data item's string data as the argument if the item's kind is a Plain unicode string (i.e., kind is string).

Link copied to clipboard
open external fun webkitGetAsEntry(): FileSystemEntry?

The webkitGetAsEntry() method of the DataTransferItem interface returns a FileSystemFileEntry or FileSystemDirectoryEntry representing the item if it is a file. If the item isn't a file, null is returned.