kostysh / File-uploading-component-for-Sencha-Touch

Ext.Button based component for uploading files in Sencha Touch apps without page refresh
51 stars 26 forks source link

Use Camera as Source Instead of a Gallery File? #24

Open designdit opened 9 years ago

designdit commented 9 years ago

Hello,

Thank you for this feature! I have been able to make it work.

I'm wondering how I can allow the user the option to upload from file or directly from the camera. Currently, even after packaging, the browse/upload function only allows files from storage. Do you know where/what I need to change to allow a picture from the camera? I have added all required permissions to the packaging.

Thank you for your help and thank you for the feature!

kostysh commented 9 years ago

with Cordova you should use "Camera" plugin: http://plugins.cordova.io/#/package/org.apache.cordova.camera

designdit commented 9 years ago

Hi, Thanks so much for your quick reply. Yes, I am using the phonegap cloud build (http://docs.build.phonegap.com/en_US/configuring_features.md.html#Features). This page includes a list of features and permissions to be added for the camera and other access. However, it doesn't seem to help. According to my packaged Android app, the app does have hardware permissions, including camera and storage, but the camera option does not appear, only the gallery and file options appear. Do you think I need to add something different in the config.xml file? Do I also need to change any of the coding in Fileup.js or File.js or add something in my form so that files and camera are allowed for input?

This is what I have in my config.xml (had to remove the opening and closing brackets or the do not appear here:

preference name="permissions" value="none" feature name="http://api.phonegap.com/1.0/camera" feature name="http://api.phonegap.com/1.0/media" feature name="http://api.phonegap.com/1.0/file"

I had also tried adding the following, but it did not make a difference: gap:plugin name="org.apache.cordova.camera"

and this is the image capture portion of my form, where myupfile is an extension of Fileup.js:

      {
  itemId: 'fileBtn',
        xtype: 'myupfile',
        iconCls: 'action',
        margin: '10px',
        iconMask: true,
        browse: {
           text: '',
         //  cls: Ext.baseCSSPrefix + 'fileup',
         //  cls: 'filebrowse',            
           ui: 'filebrowse'
           },
        autoUpload: true,
    url: 'http:...',
        name: 'files'
      }, 

Thank You!

kostysh commented 9 years ago

native cordova Camera plugin is not related to Fileup component. This is completely different feature. This plugin has own javascript API. Configuration of camera plugin has no effect to Fileup functionality.

If you enable access to camera via feature config and you have no access to Camera in Fileup - this can be a device (or Android version) related trouble. Try to test your app in Android emulator.

designdit commented 9 years ago

Thanks again for your quick reply. It's helpful to know that I don't need to change any coding in the program. I have tried with 2 devices so far with no luck (no camera option), but will try in the emulator, as you've suggested. I'll post if I find the issue.

Thank you!

designdit commented 9 years ago

Still no luck...is it at all possible that I need to change the form to accept something like:

    handler: function(){
        Ext.device.Camera.capture({
            success: function(
            ???
        },                

instead of or in addition to:

    browse: {
       text: '',       
       ui: 'filebrowse'
       },

I keep seeing references to Ext.device.Camera.capture to allow both options - camera and input from an existing file, but have no idea how to combine it with the already working code from your example.

Thanks

designdit commented 8 years ago

Thanks again, the upload works great. I've been able to get the camera to open - instead of only files/gallery, and this is the change that allows it. Instead of using:

itemId: 'fileLoadBtn', xtype: 'fileupload',

use itemId: 'fileLoadBtn', xtype: 'button',

and the controller code for phonegap's camera (including sourceType: navigator.camera.PictureSourceType.CAMERA). With the simple button xtype, the camera opens fine. However, then, of course, the fileupload coding is not called. If I used the same phonegap coding and sourceType with xtype: 'fileupload', the camera is not offered as an option, only the gallery and other phone storage. How can I get 'fileupload' to also include the camera?

Thanks

kostysh commented 8 years ago

Hi,

component xtype: 'fileupload' is extended from Ext.Button. The main difference between button and fileupload is component template. Please try to find source of issue by yourself, because I have no time, sorry. Now I working with another technology. So far from Sencha Touch, and related development environment for Sencha not enabled.

Kostya

On Sun, Jun 21, 2015 at 9:07 PM, designdit notifications@github.com wrote:

Thanks again, the upload works great. I've been able to get the camera to open - instead of only files/gallery, and this is the change that allows it. Instead of using:

itemId: 'fileLoadBtn', xtype: 'fileupload',

use itemId: 'fileLoadBtn', xtype: 'button',

and the controller code for phonegap's camera (including sourceType: navigator.camera.PictureSourceType.CAMERA). With the simple button xtype, the camera opens fine. However, then, of course, the fileupload coding is not called. If I used the same phonegap coding and sourceType with xtype: 'fileupload', the camera is not offered as an option, only the gallery and other phone storage. How can I get 'fileupload' to also include the camera?

Thanks

— Reply to this email directly or view it on GitHub https://github.com/kostysh/File-uploading-component-for-Sencha-Touch/issues/24#issuecomment-113936584 .