Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attachment bodyURL returning file path with generic extension '.blob' #11

Closed
mrloop opened this issue Feb 14, 2013 · 2 comments
Closed

Comments

@mrloop
Copy link
Contributor

mrloop commented Feb 14, 2013

Attachment data is stored as a file with the extension .blob
Using attachment bodyURL the file path to attachment data is obtained.
I want to play a mov attachment in AVPlayer but it expects a file with a know extension, e.g. mov, m4v.

As a work around I do the following

NSError *err = nil;
NSURL* url = [[self attachmentNamed:@"question"] bodyURL];
NSURL* other = [[url URLByDeletingPathExtension] URLByAppendingPathExtension:@"mov"];
[[NSFileManager defaultManager] linkItemAtURL:url toURL:other error:&err];
[[AVPlayer alloc] initWithURL:url];

Symbolic links do not work. I then need to tidy up these linked files at some point. I thought maybe when the app terminates but this isn't good if the app is long running and lots of attachments and created and deleted. Ideally attachment data would be stored in files using the original file extension if available when created. If implemented, is this a pull request you'd accept? Is it something that you are planning on doing? Or is it not needed?
If this isn't possible is there a callback, notification, or property I could observe to tell me the data is being updated/deleted and I should delete stale file links. Thanks for any help.

@snej
Copy link
Contributor

snej commented Feb 14, 2013

The blob store doesn't know anything about filenames, and it's possible for multiple attachments to result in the same blob on disk, as long as their contents are the same. So it doesn't make sense to put an extension on a blob -- if two attachments "foo.jpeg" and "foo.JPG" are saved, with the same contents, there'd be no way to decide which extension the blob's file should have.

I'm surprised that AVPLayer depends on the filename extension; most media APIs don't, they just look at the start of the data to identify the format. Is there a different call you can use that lets you specify the media type?

@snej snej closed this as completed Feb 14, 2013
@snej
Copy link
Contributor

snej commented Feb 14, 2013

I looked at AVPlayer and related classes but didn't see any relevant API.

I suggest just deleting the link as soon as your UI is done playing the movie.

@nl nl mentioned this issue Nov 9, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants