turbolinks / turbolinks-ios

Native iOS adapter for building hybrid apps with Turbolinks 5
MIT License
881 stars 92 forks source link

Fail to upload photos in Turbolinks app #102

Closed pbmarcano closed 7 years ago

pbmarcano commented 7 years ago

Hi, this issue is similar to #91, but nothing there seems to help my situation.

So I have a form that has a few fields, and it submits perfectly fine when I leave the input type="file" field empty. (I'm using rails, so its more like <%= f.file_field :photos, multiple: true %>)

But when it has any photos or files in it, it hangs on the submit button and never actually submits the form.

Observe:

lettercreationwithphoto

Now, I opened the same project up in the good ol' Safari Web browser, and the same steps work perfectly fine as expected.

lettercreationwithphotoweb

It's a relatively boilerplate turbolinks-ios and rails app. I have a TurbolinksController that does most of the heavy lifting, and each tabbed view simply overrides the URL as per this tutorial.

I have enabled the Privacy - Camera Usage Description & Privacy - Photo Library Usage Description texts in the info.plist as well, in case you were wondering.

Here is the TurbolinksController I am using —> https://gist.github.com/pbmarcano/fba748a55931c6ca41e8caa84fbc8093

Please help. What am I missing? What don't I understand?!

zachwaugh commented 7 years ago

It's hard to troubleshoot without a reproducible sample I can run. I don't see anything in Turbolinks specifically that should affect this. A few questions/suggestions:

pbmarcano commented 7 years ago

Hi @zachwaugh,

import UIKit
import WebKit

class NewLetterViewController: UIViewController, WKUIDelegate {
    var webView: WKWebView!

    override func loadView() {
        let webConfiguration = WKWebViewConfiguration()
        webView = WKWebView(frame: .zero, configuration: webConfiguration)
        webView.uiDelegate = self
        view = webView
    }

    override func viewDidLoad() {
        super.viewDidLoad()

        let myURL = URL(string: "\(host)/letters/new")
        let myRequest = URLRequest(url: myURL!)
        webView.load(myRequest)
    }
}
pbmarcano commented 7 years ago

If it helps you identify my problem, and if you don't mind, I'll happily grant you access to the repo for the rails app & the iOS app.

pbmarcano commented 7 years ago

Turns out, I was able to overcome this buy using this gem in Rails: https://github.com/JangoSteve/remotipart

annieogrady commented 7 years ago

@pbmarcano - what version of Rails are you using? We have same issue. Do you know if gem works on rails 5?

pbmarcano commented 7 years ago

@annieogrady Yep, using Rails 5.

gem 'remotipart', '~> 1.3', '>= 1.3.1' is in my Gemfile

and

//= require jquery2
//= require materialize-sprockets
//= require turbolinks
//= require jquery_ujs
//= require jquery.remotipart
//= require_tree .

is my app/assets/javascripts/application.js.

The documentation suggest you put //= require jquery.remotipart immediately after loading jquery_ujs.

I ran into issues if I loaded any conflicting javascript afterwards. So I made it the very last import before require_tree.. Hope this helps you.

annieogrady commented 7 years ago

thanks for quick response - going to give it a try…

On Thu, Aug 31, 2017 10:39 AM, Pete Marcano notifications@github.com wrote: @annieogrady Yep, using Rails 5.

gem 'remotipart', '~> 1.3', '>= 1.3.1' is in my Gemfile

and

//= require jquery2 //= require materialize-sprockets //= require turbolinks //= require jquery_ujs //= require jquery.remotipart //= require_tree .

is my app/assets/javascripts/application.js.

The documentation suggest you put //= require jquery.remotipart immediately after loading jquery_ujs.

I ran into issues if I loaded any conflicting javascript afterwards. So I made it the very last import before require_tree.. Hope this helps you.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

Annie O'GradyCo-founderAgentBright, Inc3544 Crown Point RoadLouisville, TN 37777 860-575-6950

pbmarcano commented 7 years ago

I no longer have this issue, so I am closing this.