[File Plugin] Upload file from phone storage

[File Plugin] Upload file from phone storage

  
Forge Component
(1)
Published on 5 Mar by OutSystems Experts
1 vote
Published on 5 Mar by OutSystems Experts

I'm trying to create an app which requires uploading of a photo. I've seen the File Plugin, but am unable to understand it. I want it to display some phone storage folder from where the user is allowed to choose an image. Is this possible?

Hello Saurav.

If you want to allow the user to choose from the phone's gallery, the Camera Plugin allows this by changing the default parameters in the TakePictureJS:

Looking at the Camera Plugin documentation:

"If Camera.sourceType is Camera.PictureSourceType.PHOTOLIBRARY or Camera.PictureSourceType.SAVEDPHOTOALBUM, then a dialog displays that allows users to select an existing image."


Thanks

Can you please provide more detail on this ow to access the camera photos already taken before, I I look in m JS it is listed as below on ver 5, Where do I need to make the changes


navigator.camera.getPicture(function(imageData) {
    $parameters.Success = true;
    $parameters.ImageCaptured = imageData;
    $resolve();
}, function (message) {
    $parameters.Success = false;
    $parameters.ErrorMessage = message;
    $parameters.ImageCaptured = "";
    $resolve();
}, {
    quality: 60,  destinationType: Camera.DestinationType.DATA_URL,
    encodingType: Camera.EncodingType.JPEG, targetWidth: 600,
    targetHeight: 600, correctOrientation: true
});

Hello Neville.

You need to pass another parameter. Something like:


navigator.camera.getPicture(function(imageData) {
    $parameters.Success = true;
    $parameters.ImageCaptured = imageData;
    $resolve();
}, function (message) {
    $parameters.Success = false;
    $parameters.ErrorMessage = message;
    $parameters.ImageCaptured = "";
    $resolve();
}, {
    quality: 60,  destinationType: Camera.DestinationType.DATA_URL,
    encodingType: Camera.EncodingType.JPEG, 

    sourceType: Camera.PictureSourceType.PHOTOLIBRARY,

    targetWidth: 600,
    targetHeight: 600, correctOrientation: true
});


More info on the documentation. Let me know if it helps.

Thanks