DrupalGap
DrupalGap copied to clipboard
Uploading (multiple) media files from your phone
If someone is looking for a solution to upload upload (multiple) videos, images and audio files from a smartphone he is welcome to have a look at my fork of the DG media module:

Currently is supports the image field, file field and the Webform Multiple File Component.
See also: #816 #748 #491 #178
Content type: Audio file -> is File (field type) with audio upload (widget)
Content type: Audio file2 -> is Multimedia Asset (field type) with Media Browser (widget).
In DrupalGap display
1st-> Audio Player only
2nd-> Media
None of them seem to work. The second content type is using your Media Plugin, i suppose. Also i am using your fork of drupalgap(https://github.com/luxio/DrupalGap). When i press Upload Audio nothing happens.
@rokoG: Thanks for trying.
Are the cordova-plugin-media-capture, cordova-plugin-file-transfer and cordova-plugin-dialogs enabled ?
Also i am using your fork of drupalgap(https://github.com/luxio/DrupalGap)
It should also work with the default DrupalGap version.
All three plugins mentioned in your answer
are already installed. Although in config.xml are not all mentioned.
<plugin name="cordova-plugin-whitelist" spec="1" />
<plugin name="cordova-plugin-console" spec="~1.0.6" />
<plugin name="cordova-plugin-device" spec="~1.1.5" />
<plugin name="cordova-plugin-dialogs" spec="~1.3.2" />
<plugin name="cordova-plugin-file" spec="~4.3.2" />
<plugin name="cordova-plugin-inappbrowser" spec="~1.7.0" />
<plugin name="cordova-plugin-network-information" spec="~1.3.2" />
<plugin name="cordova-plugin-camera" spec="~2.4.0" />
<plugin name="cordova-plugin-geolocation" spec="~2.4.2" />
Am i missing some other plugin?
thank you for your time answering. You and tyler are putting a lot of effort in it. @luxio @signalpoint
Coud you share the output of
$ cordova plugin list
cordova-plugin-camera 2.4.0 "Camera" cordova-plugin-compat 1.1.0 "Compat" cordova-plugin-console 1.0.6 "Console" cordova-plugin-device 1.1.5 "Device" cordova-plugin-dialogs 1.3.2 "Notification" cordova-plugin-file 4.3.2 "File" cordova-plugin-file-transfer 1.6.2 "File Transfer" cordova-plugin-geolocation 2.4.2 "Geolocation" cordova-plugin-inappbrowser 1.7.0 "InAppBrowser" cordova-plugin-media 3.0.0 "Media" cordova-plugin-media-capture 1.4.2 "Capture" cordova-plugin-network-information 1.3.2 "Network Information" cordova-plugin-whitelist 1.3.2 "Whitelist"
@rokoG could you try
$ cordova plugin add cordova-plugin-media-capture cordova-plugin-file-transfer cordova-plugin-dialogs --save
and build again.
If still nothing happens when you click the button, could you share the output of the js console.
Agreed, if your plugins aren't showing up in the config.xml file, then it sounds like you need to run cordova plugin save to update your project's plugin config.
When adding --save parameter, indeed media plugin was added in config.xml file. But still nothing happens. Sorry but can you guide me through on how to get the javascript console output of my application? You mean guide to example.com/mobile-application and copy this js console? In /mobile-application this kind of field cannot be displayed. It displays null. No button, not anything else.
i have installed https://play.google.com/store/apps/details?id=com.brightattic.soundrecorder&hl=en&rdid=com.brightattic.soundrecorder to deal with last error and it solves last error, that it cannot handle android.provider.MediaStore.RECORD_SOUND but when i try to save the uploaded sound i get
@rokoG
Sorry but can you guide me through on how to get the javascript console output of my application? You mean guide to example.com/mobile-application and copy this js console?
No I mean to debug your android app (either using a simulator or a real device connected via USB) using Chrome. For further information have a look Get Started with Remote Debugging Android Devices.
WARNING: _drupalgap_form_render_element() - audiofield_field_widget_form() does not exist for the "file" form element!...
These messages belong to the the first field with the audio upload widget. You can remove this field. And just the the Audi File 2 field.
As mentioned above the field should have type file, you can limit this to audio, if you only allow uploading sound file extensions (like mp4, m4a, ...).
I have setup winre (http://dustint.com/post/482/getting-started-with-weinre-mobile-debugging-on-windows) and here is the console log output
So you are able to select an audio file after pressing Upload Audio?
Have you enabled the file create_raw service on your Drupal Site?
Yes i am able to select an audio file.
I went to admin/structure/services/list/drupalgap/resources and enabled(it was disabled).
create_raw
I suppose i don't have to rebuild app since it is a problem on server's behalf.
So, without rebuild app,i flushed all caches inside admin/clear caches all inside drush, but still the same behaviour. The same error as above.
I have tried with another node type in which allowed extensions are all kind of files and the same errors are produced when i select audio/video/image. Same error as above: upload error source & upload error target .
Does the user have the permission "Save file information"? Have you checked the "Recent log messages" on the Drupal site?
User role student( as the logged user in DrupalGap) has only "Save File Information" and "Get a system variable" from Services Category. Only Anonymous has not the Save File Information privilege. Recent log entries shows nothing for the specified logged in user in DG. No error. I think that upload request never reaches server. I suppose the problem lies inside DrupalGap mobile app because it says in Alert that Audio File2 Filed is required. I have never meant to flood that issue with my problem. I am continuing this in order to help others with same problem. If need be, we can meet in IRC, provide apk, provide test account credentials through IRC but i think this will not help others. I am still here if you need further information from me.
P.S. I am already more than grateful of all your help @luxio .
Hi, I also decided try this module out since it might become relavant soon for one of my projects. I decided to setup clean local installation of Drupal and DrupalGap so I'm able to debug this better.
Drupal modules:
DrupalGap 7.x-1.16 File Entity 7.x-2.0-beta3 Media 7.x-2.1 Media Field 7.x-2.1 Libraries 7.x-2.3 Services 7.x-3.19 REST Server 7.x-3.19 Views 7.x-3.16 Views JSON 7.x-1.0-alpha2
DrupalGap Modules:
Media https://github.com/luxio/media
At this point the module works as desired with "Image"-field that is using the "Media browser"-widget. But the problems occur when using the "Multimedia asset"-field (which should be used if I've understood correctly?).
"Multimedia asset"-field is displayed correctly and I'm able to take the image/video/audio and it shows up inside the form before saving, but after saving the field content is disappered.
It also seems that the upload is working since I'm able to see the data inside the file system, but somehow the "link" is missing.
Example JSON output looks like this:
{"nid":"","title":"test","type":"article","language":"und","body":{"und":[{"value":""}]},"field_tags":{"und":""},"field_image":{"und":[{"fid":"25"}]},"field_videofield":{"und":[{"value":"24"}]}}"
I noticed that the "field_image"-field is using "fid" as key and "field_videofield" has a "value"-key, could this cause the error?
@majuril Thank you for trying. Could you try to use a file field instead of the Multimedia asset field.
Does the media appear when viewing it in a browser?
Well... that did the trick! 👍 Was quite sure that I tried that before and was unable to even see the widget, but I'm glad I was wrong.
Now there is one more issue occuring: After the file is saved it automatically adds "_.txt" ending to each file and saves it as a text file to the file system. I have tried to enable only "Video" file type inside File-field settings, but it's still saved as a txt-file?
Could you check the variable services_allowed_extensions with drush vget services_allowed_extensions. It looks like the file extension is not included.
drush vget services_allowed_extensions returns:
No matching variable found. [error]
drush vset services_allowed_extensions 'jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp mp3 mynewextension'
Στις Παρ, 12 Μαΐ 2017, 11:49 ο χρήστης majuril [email protected] έγραψε:
drush vget services_allowed_extensions returns: No matching variable found. [error]
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/signalpoint/DrupalGap/issues/907#issuecomment-301021042, or mute the thread https://github.com/notifications/unsubscribe-auth/AZqa43DKj0O3_jzyVFdoZeHJjuVgZX3xks5r5B0IgaJpZM4L1CEq .
@majuril
You may have to update to the dev version of the services module or apply the patch at: https://www.drupal.org/node/2502281
Perfect @rokoG command worked
drush vset services_allowed_extensions jpg jpeg gif png txt doc xls pdf
ppt pps odt ods odp mp3 mynewextension
I will also try out the dev version and the patch. Thank you very much for you help!
@luxio I have installed the all required modules and i can upload file on mobile. The issue is that when i save the node and view the node no file was uploaded. Also when i check at web there is also no file uploaded. Actually file is not saving at directory.
Important : without Media module file is saving and working correctly.
Can you guide me how can i save image in directory.
@muhammadafzaal
Are you using an Image Field or a Media Field?
Have you checked the logs of the App and Drupal for Errors?
@luxio Thank you for your quick response. I have solved this issue. Actually in default druaplgap service "create_raw" resource was not enable .
Does this currently work with unlimited images?