etiks3 opened a new issue #635:
URL: https://github.com/apache/cordova-plugin-camera/issues/635
# Bug Report
## Problem
We have implemented the plugin to upload only "MediaType.PICTURE" media type
when selecting a picture form the gallery. However, some of our application
users are able to select .txt files instead of pictures in the gallery. When we
open the .txt file received the content is as follow:
`%2Fstorage%2Femulated%2F0%2FEpson%20iPrint%2Farr%C3%AAt%20de%20travail%20.pdf`
It sounds like the document was created from a scanner and available in the
gallery as a .pdf.
I don't know which device was used to send the file and i was not able to
reproduce such a bug on my Android device.
### What is expected to happen?
The application we have built, allows user to send us pictures from their
devices. We only authorized picture media type .jpeg or .png.
### What does actually happen?
On certain cases, users have been able to send .txt files, see Problem
section above.
## Information
<!-- Include all relevant information that might help understand and
reproduce the problem -->
### Command or Code
Here is the code I've used to select from the gallery or from the camera:
```// Get event selector to device camera source type
self.cameraSrcTypeSelector = function(e) {
var eventSrc = e.target;
var classListName = eventSrc.classList;
var srcType;
if (classListName.contains('camera')) {
srcType = Camera.PictureSourceType.CAMERA;
} else if (classListName.contains('gallery')) {
srcType = Camera.PictureSourceType.SAVEDPHOTOALBUM;
}
pictureManager(srcType);
};
```
Here are the camera options:
``` // Set all options for device camera
function setCameraOptions(srcType) {
var options = {
// Some common settings are 20, 50, and 100
quality: 50,
destinationType: Camera.DestinationType.DATA_URL,
// Dynamically set the picture source, Camera or photo
gallery
sourceType: srcType,
encodingType: Camera.EncodingType.JPEG,
mediaType: Camera.MediaType.PICTURE,
allowEdit: false,
correctOrientation: true, //Corrects Android orientation
quirks
direction: 0 // Ensure back camera is set by default
}
return options;
};
```
### Environment, Platform, Device
Linux dev environment
Android and iOS devices (But I suspect it does only happen on Android
devices)
### Version information
For example:
Cordova: 9.0.0 ([email protected])
Other Frameworks: Oracle JET 8.2.0
Operating System: Linux (Centos7)
Android Studio + XCode to emulate/simulate only
## Checklist
<!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
- [x ] I searched for existing GitHub issues
- [x ] I updated all Cordova tooling to most recent version
- [x ] I included all the necessary information above
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]