Advertisement
EvaldoMaciel

Fluig Envia Arquivo API

Dec 24th, 2019
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const enviarAnexo = function (parentId, fileName, blob, callback) {
  2.     $.ajax({
  3.         async: false,
  4.         type: "POST",
  5.         url: '/api/public/2.0/contentfiles/upload/?fileName=' + fileName,
  6.         cache: false,
  7.         contentType: 'application/octet-stream',
  8.         processData: false,
  9.         data: blob,
  10.  
  11.         error: function () {
  12.             FLUIGC.toast({
  13.                 title: '',
  14.                 message: "Falha ao enviar, tente novamente e se o problema persistir contate a equipe responsavel pelo Fluig.",
  15.                 type: 'danger'
  16.             });
  17.         },
  18.  
  19.         success: function (data) {
  20.             const today = new Date();
  21.             today.setDate(today.getDate() + 1);
  22.  
  23.             $.ajax({
  24.                 async: false,
  25.                 type: "POST",
  26.                 contentType: "application/json;",
  27.                 url: '/api/public/ecm/document/createDocument',
  28.  
  29.                 data: JSON.stringify({
  30.                     "description": fileName,
  31.                     "parentId": '' + parentId,
  32.                     "expirationDate": today.toISOString().split('T')[0],
  33.                     "attachments": [{
  34.                         "fileName": fileName
  35.                     }],
  36.                 }),
  37.  
  38.                 error: function () {
  39.                     FLUIGC.toast({
  40.                         title: '',
  41.                         message: "Falha ao enviar, tente novamente e se o problema persistir contate a equipe responsavel pelo Fluig.",
  42.                         type: 'danger'
  43.                     });
  44.                 },
  45.  
  46.                 success: function (data) {
  47.                     callback(data);
  48.                 },
  49.             });
  50.         },
  51.     });
  52. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement