Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-12512

No way to get from a FILE_URL to a DATA_URL onsuccess

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Not A Bug
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None
    • Environment:

      Android 4.0+ / iOS 9.0+

    • Flags:
      Important

      Description

      The onsuccess function of the getPicture method uses the FILE_URI to set an <img> source perfectly fine, however, the conversion of this FILE_URI to get the image data or DATA_URL is never successful no matter the means attempted. Even utilizing your posted methods to get the actual file have failed:

      window.resolveLocalFileSystemURL(imgUri, function success(fileEntry) - is not getting to the image, always results in null DATA_URL in the end.

      Our method using FILE_URI:

      navigator.camera.getPicture(function (data) {
                  setTimeout(function () {
                      StatusBar.overlaysWebView(true);
                      setTimeout(function () {
                          StatusBar.overlaysWebView(false);
                      }, 250);
                  }, 250);
                  viewModel.txtImageStatus("Loading...");
                  document.getElementById("image").src = data; 
                  viewModel.showNoImage(false);
                  document.getElementById("image").style.display = "block";
                  SavetoShipment(data);
              }, function (msg) {
                  if (!msg == "Camera cancelled.") {
                      viewModel.popVisible(true);
                      viewModel.popMessage("Failed: " + msg);
                  };
                  setTimeout(function () {
                      StatusBar.overlaysWebView(true);
                      setTimeout(function () {
                          StatusBar.overlaysWebView(false);
                      }, 250);
                  }, 250);
              }, {
                  quality: DevExpress.devices.real().platform == "ios" ? 50 : 100,
                  destinationType: Camera.DestinationType.FILE_URI,
                  saveToPhotoAlbum: false,
                  correctOrientation: true,
                  encodingType: DevExpress.devices.real().platform == "ios" ? Camera.EncodingType.PNG : Camera.EncodingType.JPEG
              });
      
      function SavetoShipment(fileURI) {
              var fileReader = new FileReader();
              fileReader.onload = function (fileLoad) {
                  viewModel.shipment.CustomerPhotoInfo = fileLoad.target.result;
              };
              fileReader.readAsDataURL(fileURI);
          }
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              kyleslack Kyle Slack
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: