Unable to open file in Preview even though I have all permissions

finderpermissionpreview

I've been storing image files on Dropbox (uploaded automatically from my phone via their "Camera Uploads" feature). I just discovered that I don't have permission to open them from my synced Dropbox folder on my computer. The error is a dialog box reading:

The file “20160622_165411.jpg” couldn’t be opened because you don’t have permission to view it.
To view or change permissions, select the item in the Finder and choose File > Get Info.

In Console, I see:

2017-02-06 08:12:33.317 Preview[15288]: PVImageContainer initWithURL:file:///Users/zipslime/Dropbox/20160622_165411.jpg failed, error = Error Domain=NSCocoaErrorDomain Code=257 "The file “20160622_165411.jpg” couldn’t be opened because you don’t have permission to view it." UserInfo={NSFilePath=/Users/zipslime/Dropbox/20160622_165411.jpg, NSUnderlyingError=0x7fea18e85bd0 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}

This only seems to happen with my computer's default program (Preview). I can open the files in Firefox, and even with Finder's Quick Look. What's going on with Preview, and how can I fix this?


Solutions I've tried:

  • Check Get Info (already shows the right permissions; see below)
  • chmod 744 and chmod 777
  • Move the files out of the Dropbox folder
  • Downloading a fresh copy of the file via the Dropbox web client does work, but is not a reasonable solution at scale.

From Get Info:

enter image description here

From Terminal:

> ls -l 20160622_165411.jpg 
-rw-r--r--@ 1 zipslime  staff   3.0M Jun 24  2016 20160622_165411.jpg

> whoami
zipslime

> chmod 777 20160622_165411.jpg 
> ls -l 20160622_165411.jpg 
-rwxrwxrwx@ 1 zipslime  staff   3.0M Jun 24  2016 20160622_165411.jpg*

> open 20160622_165411.jpg 
# still fails

I found an unusual attribute (the content was a bunch of inscrutable hex characters), but deleting it doesn't change things either.

> ls -lO@ 20160622_165411.jpg 
-rwxrwxrwx@ 1 zipslime  staff  -  3.0M Jun 24  2016 20160622_165411.jpg*    com.dropbox.attributes    83B
> xattr -d com.dropbox.attributes 20160622_165411.jpg

> open 20160622_165411.jpg 
# still fails

Best Answer

This solution on the dropbox website solved my problem. However, I'm still perplexed! Where was the secret permission that wasn't visible from Get Info, ls, or xattr? Alternate answers with explanation would be welcome.

  1. Click on the Dropbox icon in your menu bar and then click on the gear in the Notifications panel.
  2. Select 'Preferences' then click on the 'Account' tab.
  3. Hold down the 'Option' key, and the "unlink this dropbox" button will change to "Fix Permissions". Click the button while continuing to hold down Option.