Skip to content
Snippets Groups Projects
wopiapi-iframe.js 1.02 KiB
Newer Older
  • Learn to ignore specific revisions
  • const axios = require('axios');
    
    function WopiAPI() {}
    
    
    Gospodin Bodurov's avatar
    Gospodin Bodurov committed
    WopiAPI.prototype.getPassportsNewProtocol = function (resourceID, contentType) {
    
      const { publicKey, uuid, token, deviceHash } = window.viamApi.getConfig().headers;
    
      const requestConfig = {
    
    Gospodin Bodurov's avatar
    Gospodin Bodurov committed
        url: `${window.WOPI_URL}getPassportsNewProtocol`,
    
    Markin Igor's avatar
    Markin Igor committed
        method: 'POST',
    
        headers: {
    
          publicKey,
          uuid,
          token,
          deviceHash,
    
          resourceID: encodeURI(resourceID),
          contentType: encodeURI(contentType)
    
    Markin Igor's avatar
    Markin Igor committed
      return axios(requestConfig);
    
    WopiAPI.prototype.putDocument = function (resourceID, accessToken, file) {
    
    Alexey Lunin's avatar
    Alexey Lunin committed
      const { publicKey, uuid, token, deviceHash } = window.viamApi.getConfig().headers;
    
    
      resourceID = encodeURI(resourceID);
    
    Alexey Lunin's avatar
    Alexey Lunin committed
      const requestConfig = {
    
        url: `${window.WOPI_URL}files/${resourceID}/contents`,
    
    Alexey Lunin's avatar
    Alexey Lunin committed
        method: 'POST',
        headers: {
          publicKey,
          uuid,
          token,
          deviceHash
        },
        params: {
          access_token: accessToken
        },
        data: file
      };
    
      return axios(requestConfig);
    };
    
    
    module.exports = WopiAPI;