Spent a little time trying to figure this one out but since I canât seem to get the web inspector working to debug the webview context making it pretty hard to help you...
Personally, I wouldnât use a webview. Seems like there are some changes Sketch has made to the app runtime that make downloading things via a webview much harder. While there is a steeper learning curve, the cocoa apis offer quite a bit of flexibility and make this quite a bit simpler.
That being said I think you are on the right track.
- You can use the
FileReader
api to create a base64 representation.
- Send that over to the plugin js context via
window.postMessage
- Convert that bas64 string to a
NSData
object NSData.dataFromBase64String(string)
- Then write the data file to disc using
data.writeToFile_ atomically(â\path_to_where_video_will_be.mp4â,false)