This is a migrated thread and some comments may be shown as answers.

Accessing documents on a device

1 Answer 41 Views
AppBuilder Windows client
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Gerrit
Top achievements
Rank 2
Gerrit asked on 07 May 2013, 02:16 PM
Hi guys

Can you please help me out. We want to be able to browse for files, and upload them to our server from the application.
We have 2 problems now:

1. We can access files in the photo library, but not files on the memory card, how do we access files that are not stored in the photo library?
2. We want to save the location of the file, and when the user eventually decides to submit the from, the application should go and find the file in the specific location and get its base64 data and post it to the server. We do not want to save the base64 data because that will make the application very big and duplicate files on the tablet.

Please help :)

Here is the code we currently use:

/ Wait for Cordova to connect with the device
    //
    document.addEventListener("deviceready",onDeviceReady,false);

    // Cordova is ready to be used!
    //
    function onDeviceReady() {
        pictureSource=navigator.camera.PictureSourceType;
        destinationType=navigator.camera.DestinationType;
    }

    // A button will call this function
    //
    function capturePhoto() {
      // Take picture using device camera
      navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50, saveToPhotoAlbum: true,
        destinationType: destinationType.FILE_URI, 
          sourceType : Camera.PictureSourceType.CAMERA, encodingType: Camera.EncodingType.JPEG });
    }

    // A button will call this function
    //
    function getPhoto(source) {
      // Retrieve image file location from specified source
      navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 50, 
        destinationType: destinationType.DATA_URL,
        sourceType: source });
    }

    // Called when a photo is successfully retrieved
    //
    function onPhotoDataSuccess(imageURL) {
      // Uncomment to view the base64 encoded image data
      console.log(imageURL);
    }
    // Called when a photo is successfully retrieved
    //
    function onPhotoURISuccess(imageData) {
      // Uncomment to view the image file URI 
      console.log(imageData);
    }
    // Called if something bad happens.
    // 
    function onFail(message) {
      alert('Failed because: ' + message);
    }
    </script>
  </head>
  <body>
    <button onclick="capturePhoto();">Capture Photo</button> <br>
    <button onclick="getPhoto(pictureSource.SAVEDPHOTOALBUM);">From Photo Library</button><br>
    <img style="display:none;width:60px;height:60px;" id="smallImage" src="" />
    <img style="display:none;" id="largeImage" src="" />
  </body>
</html>

Kind Regards,
Gerrit

1 Answer, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 08 May 2013, 02:20 PM
Hello Gerrit,

Take a look at the following forum post (if you haven't) that elaborates on your inquiry.

All the best,
Steve
the Telerik team

Share feedback and vote for features on our Feedback Portal.
Want some Kendo UI online training - head over to Kendo UI Dojo.
Tags
AppBuilder Windows client
Asked by
Gerrit
Top achievements
Rank 2
Answers by
Steve
Telerik team
Share this question
or