Skip to content
Snippets Groups Projects
wopiapi-iframe.js 932 B
Newer Older
  • Learn to ignore specific revisions
  • const axios = require('axios');
    
    function WopiAPI() {}
    
    
    WopiAPI.prototype.getPassports = function (fileID) {
    
      const { publicKey, uuid, token, deviceHash } = window.viamApi.getConfig().headers;
    
      const requestConfig = {
    
        url: `${window.WOPI_URL}getPassports`,
    
    Markin Igor's avatar
    Markin Igor committed
        method: 'POST',
    
        headers: {
    
          publicKey,
          uuid,
          token,
          deviceHash,
    
    Markin Igor's avatar
    Markin Igor committed
      return axios(requestConfig);
    
    WopiAPI.prototype.putDocument = function (path, accessToken, file) {
    
    Alexey Lunin's avatar
    Alexey Lunin committed
      const { publicKey, uuid, token, deviceHash } = window.viamApi.getConfig().headers;
    
      path = path[0] === "/" ? path : `/${path}`;
    
    Alexey Lunin's avatar
    Alexey Lunin committed
      const requestConfig = {
    
        url: `${window.WOPI_URL}files${path}/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;