Question

When adding an attachment to an email, the file name gets it's complete path.

For a file located in:

/var/mobile/Applications/C3BBAA5F-07FE-4E26-9661-CB492E06BD2E/Documents/

I'm getting as a result, a file named:

_var_mobile_Applications_C3BBAA5F-07FE-4E26-9661-CB492E06BD2E_Documents_Clock.sqlite

When I need my filename to be:

Clock.sqlite

Here's my code:

NSString *path = [self getDatabaseFilePath];
NSData *myData = [NSData dataWithContentsOfFile:path];
[picker addAttachmentData:myData mimeType:@"application/x-sqlite3" fileName:path];

How can I get the attachment to have only the filename and extension, without the complete path?

Thank you!

Was it helpful?

Solution

This should do what you want:

NSString *path = [self getDatabaseFilePath];
NSData *myData = [NSData dataWithContentsOfFile:path];
[picker addAttachmentData:myData mimeType:@"application/x-sqlite3" fileName:[path lastPathComponent]];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top