I am generating file names that contain a timestamp in the following format:
"base_name (yyyy-mm-dd hhmmss).ext"
This seems to cause a problem on Android. Here's my log:
/storage/sdcard0/anMoney/transfer/Net worth over time _ Forecast (2012-11-19 110550).pdf
E/Gmail (11802): java.io.FileNotFoundException: /storage/sdcard0/myapp/transfer/Net worth over time _ Forecast (2012-11-19 110550).pdf: open failed: ENOENT (No such file or directory)
E/Gmail (11802): at libcore.io.IoBridge.open(IoBridge.java:416)
E/Gmail (11802): at java.io.FileInputStream.<init>(FileInputStream.java:78)
E/Gmail (11802): at java.io.FileInputStream.<init>(FileInputStream.java:105)
E/Gmail (11802): at android.content.ContentResolver.openInputStream(ContentResolver.java:445)
E/Gmail (11802): at com.google.android.gm.provider.MailEngine.cacheAttachment(MailEngine.java:3054)
E/Gmail (11802): at com.google.android.gm.provider.MailEngine.sendOrSaveDraft(MailEngine.java:2746)
E/Gmail (11802): at com.google.android.gm.provider.MailProvider.sendOrSaveDraft(MailProvider.java:477)
E/Gmail (11802): at com.google.android.gm.provider.MailProvider.insert(MailProvider.java:534)
E/Gmail (11802): at android.content.ContentProvider$Transport.insert(ContentProvider.java:201)
E/Gmail (11802): at android.content.ContentResolver.insert(ContentResolver.java:864)
E/Gmail (11802): at com.google.android.gm.provider.Gmail$MessageModification.sendOrSaveNewMessage(Gmail.java:3576)
E/Gmail (11802): at com.google.android.gm.ComposeActivity$SendOrSaveTask$1.onInitializationComplete(ComposeActivity.java:1765)
E/Gmail (11802): at com.google.android.gm.provider.MailEngine$5.run(MailEngine.java:1006)
E/Gmail (11802): at android.os.Handler.handleCallback(Handler.java:615)
E/Gmail (11802): at android.os.Handler.dispatchMessage(Handler.java:92)
E/Gmail (11802): at android.os.Looper.loop(Looper.java:137)
E/Gmail (11802): at android.os.HandlerThread.run(HandlerThread.java:60)
E/Gmail (11802): Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
Now, if I trim the file name to have only 16 characters within the parentheses, everything is working as expected. I am able to send the file as a GMail attachment.
The following file name is working fine:
/storage/sdcard0/myapp/transfer/Net worth over time _ Forecast (2012-11-19 11070).pdf
I tried the following troubleshooting:
It's not the overall length of the file name, as if I shorten the base name, the same behavior remains
It's not GMail, uploading the file to Google Drive fails similarly
16 characters inside the parentheses work, but not 17
It's not the space character inside the parentheses that causes the issue, as I replaced it with a dash and it's the same problem.
Anybody has any ideas on what's going on here?