Closed hohonuuli closed 1 year ago
Sanity checks:
scala-cli repl
)Spaces are allowed in file URLs in Java.
scala> import java.net.URL
scala> val url = new URL("file:/Users/brian/.vars/images/Doc Ricketts 1461 20221002T192205Z--cf5f53ef-8577-416d-abb6-325806b37856--20221212T230634.782Zpng")
val url: java.net.URL = file:/Users/brian/.vars/images/Doc Ricketts 1461 20221002T192205Z--cf5f53ef-8577-416d-abb6-325806b37856--20221212T230634.782Zpng
swift repl
)Spaces fail in URLs in Swift. Replacing with %20
works.
1> import Foundation
2> let url = URL(string: "file:/Users/brian/.vars/images/Doc Ricketts 1461 20221002T192205Z--cf5f53ef-8577-416d-abb6-325806b37856--20221212T230634.782Zpng")
url: Foundation.URL? = nil
3> let url = URL(string: "file:/Users/brian/.vars/images/Doc%20Ricketts%201461%2020221002T192205Z--cf5f53ef-8577-416d-abb6-325806b37856--20221212T230634.782Zpng")
url: Foundation.URL? =
"file:/Users/brian/.vars/images/Doc%20Ricketts%201461%2020221002T192205Z--cf5f53ef-8577-416d-abb6-325806b37856--20221212T230634.782Zpng"
Sanity Check:
scala> import java.nio.*
scala> import java.nio.file.*
scala> val p = Paths.get("/Users/brian/.vars/images/Doc Ricketts 1461 20221002T192205Z--cf5f53ef-8577-416d-abb6-325806b37856--20221212T230634.782Zpng")
scala> p.toUri()
val res2: java.net.URI = file:///Users/brian/.vars/images/Doc%20Ricketts%201461%2020221002T192205Z--cf5f53ef-8577-416d-abb6-325806b37856--20221212T230634.782Zpng
I believe the HTTP URL spec does not allow spaces, and Swift is adhering strictly whereas Java is lenient. It should be a simple matter to urlEncode the URL. But if this an backward compatibility issue, we can urlEncode the incoming "URL"
In the spec, framecapture always sends a path to a local file. If I remember correctly, the URL conversion is internal to Sharktopoda .In any case, the remote app will be sending a path to a file that will often include spaces.
Ah, right. I was remembering the field as being url
🤦🏽♂️. I'll fix to urlEncode the path
while forming the file:
URL.
Proposed fix: commit 4db50192995a1fa7f9ccc9fa8c6ab0b3723f1b79
Resolved. Ran test using
mvn install -Dmaven.test.skip=true
mvn exec:java -Dexec.mainClass=org.mbari.vcr4j.examples.remote.Issue21 -Dexec.args="8800 http://varsdemo.mbari.org/media/M3/mezzanine/Ventana/2017/03/4003/V4003_20170301T185553.933Z_t2s4_hd_tc01495915_h264.mp4" -pl vcr4j-examples
Comms shows the correct time is reported
2022-12-23 08:26:45 [org.mbari.vcr4j.examples.remote.Issue21.main()] DEBUG org.mbari.vcr4j.remote.control.RemoteControl$Builder - Building. Listening on port 5555. Sending commands to localhost:8800
2022-12-23 08:26:45 [org.mbari.vcr4j.examples.remote.Issue21.main()] DEBUG org.mbari.vcr4j.remote.player.PlayerIO - anicca.lan:5555 - Started server's receiver thread: Thread-1
2022-12-23 08:26:45 [Thread-1] DEBUG org.mbari.vcr4j.remote.player.PlayerIO - anicca.lan:5555 - Received command <<< {"command":"open done","status":"ok","uuid":"1b1fd0a0-52d8-4740-9350-d9c98fa9ac5f"}
2022-12-23 08:26:45 [Thread-1] DEBUG org.mbari.vcr4j.remote.player.PlayerIO - anicca.lan:5555 - Responding >>> {
"response": "open done",
"status": "ok"
}
2022-12-23 08:26:49 [Thread-1] DEBUG org.mbari.vcr4j.remote.player.PlayerIO - anicca.lan:5555 - Received command <<< {"command":"frame capture done","elapsedTimeMillis":810509,"imageLocation":"/Users/brian/workspace/M3/vcr4j/trashme 810521.png","imageReferenceUuid":"78b6ae9f-f8af-4048-bc4c-6857fec4bb91","status":"ok","uuid":"1b1fd0a0-52d8-4740-9350-d9c98fa9ac5f"}
2022-12-23 08:26:49 [Thread-1] DEBUG org.mbari.vcr4j.remote.player.PlayerIO - anicca.lan:5555 - Responding >>> {
"response": "frame capture done",
"status": "ok"
}
The frame capture command should be able to handle paths with spaces in them. For example:
But Sharktopoda responds to those with:
Maybe the conversion to a file URL still requires escaping the paths? (using
%20
). The path on disk should still include the spaces though.Log output