1

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!

nmdias
  • 3,888
  • 5
  • 36
  • 59

1 Answers1

2

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]];
Kevin
  • 1,506
  • 9
  • 12