Skip to main content

  function upload_image(e, template) {

      $("#loader_class").removeClass("div_hide_class");
      if (e.currentTarget.files && e.currentTarget.files[0]) {
          var file = e.currentTarget.files[0];

          var  chunkSize = Infinity;

      var options = {
          endpoint: "http://13.232.101.233:8000/uploads",
          chunkSize: chunkSize,
          metadata: {
              filename: file.name,
              user_id: "Ankit",
          },
           header: {
              "key":"value"
          },
          beforeSend: function(xhr){xhr.setRequestHeader('X-Test-Header', 'test-value');},
          onError: function(error) {
              if (error.originalRequest) {
                  if (confirm('Failed because: ' + error + '\nDo you want to retry?')) {
                      options.resume = false;
                      options.uploadUrl = upload.url;
                      upload = new tus.Upload(file, options);
                      upload.start();
                      return;
                  }
              } else {
                  alert('Failed because: ' + error);
              }

          },
          onProgress: function(bytesUploaded, bytesTotal) {
              var percentage = (bytesUploaded / bytesTotal * 100).toFixed(2);
              console.log(bytesUploaded, bytesTotal, percentage + '%');
          },
          onSuccess: function(data) {
         
        var uploaded_url  = upload.url;
        var final_url  = uploaded_url.replace("8000","3000");
          alert(final_url);
        var type =  file.type;

             if(type.includes("video")) {
              Session.set("post_type","video");
              Session.set("media_url",final_url);
               Session.set("video_url",final_url);
           
             var vid = document.getElementById("my_video_1");
             vid.src = final_url;

          }

          else if(type.includes("image")){
                Session.set("post_type","image");
                Session.set("media_url",final_url);
                 $("#post_image").attr("src",final_url);       
           }

           else if(type.includes("audio")){
                 Session.set("post_type","audio");
                 Session.set("media_url",final_url);
                  $("#audio_file").attr("src",final_url);
          }
          else{
                if(type.includes("powerpoint")){
                Session.set("post_type","powerpoint_doc");
                $("#document_image").attr("src","/images/ppt.svg");
                }else if(type.includes("msword")){
                  Session.set("post_type","word_doc");
                $("#document_image").attr("src","/images/docx.svg");
                 
                }else if(type.includes("pdf")){
                 Session.set("post_type","pdf_doc");
                $("#document_image").attr("src","/images/pdf.svg");
                }

                Session.set("media_url",final_url);
                $("#document_div").removeClass("div_hide_class");
              }
            var post_type = Session.get("post_type");
            updateViews(Session.get("post_type"));
            $("#loader_class").hide();
        }
      };
      upload = new tus.Upload(file, options);
      upload.start();
  }
  }

Comments

Popular posts from this blog

Meteor JS REST API

WRITE A POST Shahid Shaikh FOLLOW Engineer, Blogger from Mumbai. RESTful CRUD Operations in Meteor.js Published Dec 31, 2015 Last updated Jan 19, 2017 Introduction Meteor is a popular framework for building real-time web applications. We have already covered a tutorial which explains  how to build chat system using Meteor.js . In this tutorial, we will learn how to develop a RESTful API using Meteor which perform CRUD operations. Creating new project Create a new meteor project using the following command: meteor create appName Choose an application name of your choice. Once Meteor is done creating the project, you will see the directories and files created by Meteor in the folder name. We will not need them as of now, so we will delete all of those files and create whatever we need in the coming section. Installing iron-router In order to perform routing in Meteor, we will use  this awesome package . Run the

COnfigure Orthanc

cmake -DSTATIC_BUILD:BOOL=ON -DCMAKE_BUILD_TYPE=Debug cmake "-DDCMTK_LIBRARIES=wrap;oflog" -DSTATIC_BUILD=OFF -DDEBIAN_USE_GTEST_SOURCE_PACKAGE:BOOL=ON -DCMAKE_BUILD_TYPE=Debug SRC https://bitbucket.org/sjodogne/orthanc/src/default/LinuxCompilation.txt?fileviewer=file-view-default # How to compile, install and run newest version of Orthanc DICOM server # from Github source in Ubuntu 16.04 LTS cd sudo apt-get update sudo apt-get install build-essential unzip cmake mercurial uuid-dev libcurl4-openssl-dev liblua5.1-0-dev libgtest-dev libpng-dev libsqlite3-dev libssl-dev libjpeg-dev zlib1g-dev libdcmtk2-dev libboost-all-dev libwrap0-dev libcharls-dev libjsoncpp-dev libpugixml-dev doxygen qupzilla sudo rm -rf Orthanc* sudo apt-get purge orthanc git clone https://github.com/jodogne/OrthancMirror.git mkdir ~/OrthancBuild cd ~/OrthancBuild/ cmake -DSTATIC_BUILD=ON -DCMAKE_BUILD_TYPE=Release ~/OrthancMirror/ sudo make sudo make doc ./Orthanc --version ./Orthanc & qupzill