DeviceStorage.addNamed()
#
SummaryThe addNamed method is used to add a file inside a given storage area.
This method allows to choose the name of the file. However, if a file with the same name already exists, this method will fail. It's not possible to override a file. To update or modify a file, you have to pick it first with the getEditable or enumerateEditable method.
Note: Repository in a storage area is implicit; it's not possible to explicitly create an empty repository. If you want to use a repository structure you have to make it part of the name of the file to store. So if you want to store the file bar inside the
foo
repository, you have to provide the complete path name of the file:addNamed(blob, "foo/bar")
.As files are added in a given restricted storage area, for security reasons, a file path name cannot start with "
/
" nor "../
" (and "./
" is pointless).
#
Syntax#
Parametersfile
A Blob object representing the file to add (note that a File object is also a Blob object).name
A string representing the full name (path + file name) of the file.
#
ReturnsIt returns a DOMRequest object to handle the success or error of the operation.