src/dropbox.js
function (path) {
    var url = 'https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings';
    var options = {
      body: {path: getDropboxPath(path)}
    };

    return this._request('POST', url, options).then((response) => {
      if (response.status !== 200 && response.status !== 409) {
        return Promise.reject(new Error('Invalid response status:' + response.status));
      }

      var body;

      try {
        body = JSON.parse(response.responseText);
      } catch (e) {
        return Promise.reject(new Error('Invalid response body: ' + response.responseText));
      }

      if (response.status === 409) {
        if (compareApiError(body, ['shared_link_already_exists'])) {
          return this._getSharedLink(path);
        }

        return Promise.reject(new Error('API error: ' + body.error_summary));
      }

      return Promise.resolve(body.url);
    }).then((link) => {
      this._itemRefs[path] = link;

      if (hasLocalStorage) {
        localStorage.setItem(SETTINGS_KEY+':shares', JSON.stringify(this._itemRefs));
      }

      return Promise.resolve(link);
    }, (error) => {
      error.message = 'Sharing Dropbox file or folder ("' + path + '") failed: ' + error.message;
      return Promise.reject(error);
    });
  }
function (path) {
    var url = 'https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings';
    var options = {
      body: {path: getDropboxPath(path)}
    };

    return this._request('POST', url, options).then((response) => {
      if (response.status !== 200 && response.status !== 409) {
        return Promise.reject(new Error('Invalid response status:' + response.status));
      }

      var body;

      try {
        body = JSON.parse(response.responseText);
      } catch (e) {
        return Promise.reject(new Error('Invalid response body: ' + response.responseText));
      }

      if (response.status === 409) {
        if (compareApiError(body, ['shared_link_already_exists'])) {
          return this._getSharedLink(path);
        }

        return Promise.reject(new Error('API error: ' + body.error_summary));
      }

      return Promise.resolve(body.url);
    }).then((link) => {
      this._itemRefs[path] = link;

      if (hasLocalStorage) {
        localStorage.setItem(SETTINGS_KEY+':shares', JSON.stringify(this._itemRefs));
      }

      return Promise.resolve(link);
    }, (error) => {
      error.message = 'Sharing Dropbox file or folder ("' + path + '") failed: ' + error.message;
      return Promise.reject(error);
    });
  }
Gets a publicly-accessible URL for the path from Dropbox and stores it
in ``_itemRefs``.

@return {Promise} a promise for the URL

@private