Ionic-native: File.writeFile() not creating file.

Created on 27 Sep 2017  Â·  6Comments  Â·  Source: ionic-team/ionic-native

_From @husainkhan on September 27, 2017 12:48_

Ionic version: (check one with "x")
(For Ionic 1.x issues, please use https://github.com/ionic-team/ionic-v1)
[ ] 2.x
[x] 3.x
[ ] 4.x

I'm submitting a ... (check one with "x")
[x] bug report
[ ] feature request

Current behavior:
I am trying to create a file using writeFile() of File and attach the same to the email on the success callback.However, the file is never created and the email application does not open.If I remove the attachment from the email(file path to the created), the email application opens.Also I am unable to find the file in explorer.

Expected behavior:
Without the bug, the file would be created and would be attached on the email.

Steps to reproduce:
Sample code
this.file.writeFile(this.file.dataDirectory, 'test.csv', 'hello,world,', {replace: true})
.then(() => {
let email = {
to: 'email@email',
attachments: [this.file.dataDirectory + 'test.csv'],
subject: 'subject',
body: 'body text...',
isHtml: true
};
this.emailComposer.open(email);
})
.catch((err) => {
console.error(err);
});

Related code:

Other information:
I have not been able to find this issue anywhere.On other issues, the writer was creating file but not writing into it but in my case the file is not being created.

Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):

cli packages: (C:\Users\HK491441\AppData\Roaming\npm\node_modules)

    @ionic/cli-plugin-proxy : 1.4.11
    @ionic/cli-utils        : 1.12.0
    ionic (Ionic CLI)       : 3.12.0

global packages:

    cordova (Cordova CLI) : not installed

local packages:

    @ionic/app-scripts : 2.1.4
    Cordova Platforms  : android 6.2.3 browser 4.1.0
    Ionic Framework    : ionic-angular 3.6.1

System:

    Android SDK Tools : 26.0.2
    Node              : v7.6.0
    npm               : 5.3.0
    OS                : Windows 7

Misc:

    backend : legacy

_Copied from original issue: ionic-team/ionic#12996_

improve docs improve plugin

Most helpful comment

Hi Mayur,

Android no longer allow creating files in the data directory, try creating
it else where and it would work.

Regards,
Husain Khan

On Mon, 9 Sep, 2019, 2:53 AM Mayur Rawte, notifications@github.com wrote:

any updates on this?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/ionic-team/ionic-native/issues/2001?email_source=notifications&email_token=ADMAFFOQNWFENXIF4E73473QIVUORA5CNFSM4D4XR7U2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6FZXJA#issuecomment-529243044,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADMAFFKAOBU25ZBYM63SYODQIVUORANCNFSM4D4XR7UQ
.

All 6 comments

Hello! Thank you for opening an issue with us! Would you be able to provide a sample application via GitHub that demonstrates the issue you are having?

This does not sound like an Ionic Framework issue. This appears to be an issue you are having with one or more of the ionic-native plug-ins, so I am going to move this issue over there. Please follow-up using the issue that is created over there.

Thanks for using Ionic!

Resolved the issue!
Android no longer allows data to be written in Data directory.The plugin specification is incomplete.

How did you solve this bug? I have the same problem.

any updates on this?

Hi Mayur,

Android no longer allow creating files in the data directory, try creating
it else where and it would work.

Regards,
Husain Khan

On Mon, 9 Sep, 2019, 2:53 AM Mayur Rawte, notifications@github.com wrote:

any updates on this?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/ionic-team/ionic-native/issues/2001?email_source=notifications&email_token=ADMAFFOQNWFENXIF4E73473QIVUORA5CNFSM4D4XR7U2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6FZXJA#issuecomment-529243044,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADMAFFKAOBU25ZBYM63SYODQIVUORANCNFSM4D4XR7UQ
.

Hello,
Try writing it in external data directory for Android.

Was this page helpful?
0 / 5 - 0 ratings