Creates a background transfer operation to upload a file to Microsoft OneDrive. This is an async method that returns a Promise object that allows you to attach events to handle succeeded and failed situations.
Required. A JSON object that contains the following properties, which are necessary to make the REST API call.
Name Type Description Default Value
Required. The path to the file to upload.
Optional. The name of the file to upload.
Windows.Storage.StorageFile or File
Optional. The file input object to read the file from.
Optional. The file input stream to read the file from.
boolean or string
Optional. Indicates whether the uploaded file should overwrite an existing copy. Specify true or "true" to overwrite, false or "false" to not overwrite and for the WL.createBackgroundUpload method call to fail, or "rename" to not overwrite and enable OneDrive to assign a new name to the uploaded file.
Optional. Specifies a callback function that is executed when upload call is complete. The callback function takes the API response object as a parameter. The response object exposes the data returned from the Live SDK, or if an error occurs, an error property that contains the error code.
Note Although the callback parameter is still supported, we recommend that you use the Promise object instead, which is described later in this topic.
Returns a Promise object. This object allows you to attach events to handle succeeded, failed, and progressed situations.
An upload operation consists of:
- A Guid property that allows you to track the upload operation.
start()method to start the operation.
If the call is successful, you will receive a download operation in the onSuccess event.
Important Before calling the WL.createBackgroundUpload function, your code must call either the WL.init or WL.login function with, at minimum, the required scopes for uploading the corresponding file. If you don't do this, the upload operation created from the WL.createBackgroundUpload function may fail. Also, this requirement applies to each webpage's current session. Therefore, if your app contains multiple webpages, each webpage must follow this requirement.
Minimum supported client
|Windows 8.1 [Windows Store apps only]|
Minimum supported server
|None supported [Windows Store apps only]|
Minimum supported phone
|Windows Phone 8.1|