1

I am developing an Android and iOS webapp using Turbolinks.

I'm trying to implement taking a new picture or selecting one from the gallery using the native views/process.

I have this line in my form

<input type="file" accept="image/*" capture="camera" id="capture"> 

It works as expected when I visit my webapp through the browser. However, clicking the input while running the Turbolinks app does nothing. I suspect it is because the input field is not a link, so does not trigger visitProposedToLocationWithAction().

How can I manually trigger the native photo taking/selecting flow when this input is clicked?

tinOfBeans
  • 707
  • 1
  • 9
  • 22

1 Answers1

2

I ended up using carrierwave. If you follow the instructions and add it to your model it works just fine.

More specifically, that input line would change to

<%= f.file_field :image, id: "image-select", class: 'form-control' %>
tinOfBeans
  • 707
  • 1
  • 9
  • 22
  • You did not need to and anything else in the activity or javascript or anything? I set up carrierwave as per their instructions and have it working fine from web, but no luck in android or iOS apps. Remotipart made iOS uploads work, but still nothing happens when clicking android "choose file" button. – Lee Quarella Jan 04 '18 at 19:22
  • @LeeQuarella You have to include onShowFileChooser https://developer.android.com/reference/android/webkit/WebChromeClient.html in the onCreate method. Also [see this](https://github.com/turbolinks/turbolinks-android/issues/53). This was a while ago so I don't remember if this was all that was required. – tinOfBeans Jan 31 '18 at 20:00