Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accepting files: namesOfPromisedFilesDroppedAtDestination opens Finder window

I have a NSView to accept files from all the sources - local and remote. I use NSFilesPromisePboardType to accept remote files like images dragged from the browser. Here is the code I use to get dropped images to be copied into my folder:

- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
{
    NSPasteboard * pboard = [sender draggingPasteboard];
    NSDragOperation sourceDragMask = [sender draggingSourceOperationMask];

    if ([[pboard types] containsObject:NSFilesPromisePboardType])
    {
        [sender namesOfPromisedFilesDroppedAtDestination:_fileStorageFolder];
        return YES;
    }

    return NO;
}

And now I have noticed 2 issues:

  1. "Looked for HFSPromises on the pasteboard, but found none." warning is printed into the debug console.
  2. Finder opens a new window to show and highlight the newly downloaded file.

What is the correct way to receive files from browser without any warnings and Finder windows?

like image 425
UJey Avatar asked Nov 02 '22 12:11

UJey


1 Answers

Answering my own question. There was nothing wrong with my code. It was the latest version of Google Chrome that opened Finder window after you drag&drop file from the browser to any location on your computer.

I found a bug-report for Google Chrome, tested Opera and Safari - everything is ok.

Sorry for bothering.

like image 57
UJey Avatar answered Nov 09 '22 03:11

UJey