Export (0) Print
Expand All

WL.createBackgroundUpload function

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.

Important  WL.createBackgroundUpload is supported only for use with Windows Runtime apps using JavaScript. If you are writing a web app, use WL.upload instead.

Parameters

properties

Required. A JSON object that contains the following properties, which are necessary to make the REST API call.

NameTypeDescriptionDefault Value

path

string

Required. The path to the file to upload.

None

file_name

string

Optional. The name of the file to upload.

None

file_input

Windows.Storage.StorageFile or File

Optional. The file input object to read the file from.

None

stream_input

Windows.Storage.Streams.IInputStream

Optional. The file input stream to read the file from.

None

overwrite

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.

"false"

 

callback

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.

Return value

Returns a Promise object. This object allows you to attach events to handle succeeded, failed, and progressed situations.

Remarks

An upload operation consists of:

  • A Guid property that allows you to track the upload operation.
  • A 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.

Requirements

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

Library

Wl.js

DLL

N/A

 

 

Show:
© 2014 Microsoft