Download content of public.file-url when Finder does the paste action

Hello, Is it possible fill NSpastebard with public.file-url which will initially point the an empty file. And when Finder will paste the file, my Application will download it and Finder will wait for the completion of the download.

My goal is not to use drag & drop.

I saw that Microsoft RDP client is doing file download using this way. But I don't know how it works. Empty file is created in sandbox.

Answered by ddoe99 in 773318022

NSFilePresenter seem to be what I need. An exemple is done here https://github.com/lemonmojo/RemoteFilesVsPasteboard

The word you’re looking for here is promise. You vend a file promise and the receiver calls in that promise after the drop. I don’t know how to do that with AppKit [1] but knowing the right search term should help you find the info you need.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] I could tell you how to do it with the traditional Mac OS Drag Manager, but I don’t think that’ll help you very much (-:

Accepted Answer

NSFilePresenter seem to be what I need. An exemple is done here https://github.com/lemonmojo/RemoteFilesVsPasteboard

Download content of public.file-url when Finder does the paste action
 
 
Q