Nativescript - file system overwrite not working on Android











up vote
1
down vote

favorite












I'm new to NativeScript.



I'm using nativescript-plugin-firebase to download the photo of the user and save it into /data/user/0/{APP_ID}/files/telerik-logo-downloaded.png.



Firebase Storage Native API Example:



var fs = require("tns-core-modules/file-system");

// let's first determine where we'll create the file using the 'file- system' module
var documents = fs.knownFolders.documents();
var logoPath = documents.path + "/telerik-logo-downloaded.png";

// this will create or overwrite a local file in the app's documents folder
var localLogoFile = documents.getFile("telerik-logo-downloaded.png");

// now download the file with either of the options below:
firebase.storage.downloadFile({
bucket: 'gs://n-plugin-test.appspot.com',
remoteFullPath: 'uploads/images/telerik-logo-uploaded.png',
localFile: fs.File.fromPath(logoPath),
localFullPath: logoPath
}).then(
function (uploadedFile) {
console.log("File downloaded to the requested location");
},
function (error) {
console.log("File download error: " + error);
}
);


When there's a change(e.g. user uploads a new photo), I will download the photo with the Firebase Storage Native API and overwrite the existing one.



var localLogoFile = documents.getFile("telerik-logo-downloaded.png");


this code above should overwrite the local file if it's existing.



In the result, the new photo will be shown on iOS but not Android. For Android, it's still the old photo.



May anyone help? Thank you~










share|improve this question
























  • hello @felicia, may I ask how do you load the photo?
    – vann_goh
    Nov 9 at 13:20










  • Thanks for replying @vann_goh, this way img.src = logoPath, is there any problem?
    – Felicia
    Nov 9 at 13:22










  • may you try to change the way you load the photo as I comment below? Tell me if it works ;)
    – vann_goh
    Nov 9 at 13:26










  • Oh yeah!!! Thank you soooo much @vann_goh!!! It works
    – Felicia
    Nov 9 at 14:27















up vote
1
down vote

favorite












I'm new to NativeScript.



I'm using nativescript-plugin-firebase to download the photo of the user and save it into /data/user/0/{APP_ID}/files/telerik-logo-downloaded.png.



Firebase Storage Native API Example:



var fs = require("tns-core-modules/file-system");

// let's first determine where we'll create the file using the 'file- system' module
var documents = fs.knownFolders.documents();
var logoPath = documents.path + "/telerik-logo-downloaded.png";

// this will create or overwrite a local file in the app's documents folder
var localLogoFile = documents.getFile("telerik-logo-downloaded.png");

// now download the file with either of the options below:
firebase.storage.downloadFile({
bucket: 'gs://n-plugin-test.appspot.com',
remoteFullPath: 'uploads/images/telerik-logo-uploaded.png',
localFile: fs.File.fromPath(logoPath),
localFullPath: logoPath
}).then(
function (uploadedFile) {
console.log("File downloaded to the requested location");
},
function (error) {
console.log("File download error: " + error);
}
);


When there's a change(e.g. user uploads a new photo), I will download the photo with the Firebase Storage Native API and overwrite the existing one.



var localLogoFile = documents.getFile("telerik-logo-downloaded.png");


this code above should overwrite the local file if it's existing.



In the result, the new photo will be shown on iOS but not Android. For Android, it's still the old photo.



May anyone help? Thank you~










share|improve this question
























  • hello @felicia, may I ask how do you load the photo?
    – vann_goh
    Nov 9 at 13:20










  • Thanks for replying @vann_goh, this way img.src = logoPath, is there any problem?
    – Felicia
    Nov 9 at 13:22










  • may you try to change the way you load the photo as I comment below? Tell me if it works ;)
    – vann_goh
    Nov 9 at 13:26










  • Oh yeah!!! Thank you soooo much @vann_goh!!! It works
    – Felicia
    Nov 9 at 14:27













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I'm new to NativeScript.



I'm using nativescript-plugin-firebase to download the photo of the user and save it into /data/user/0/{APP_ID}/files/telerik-logo-downloaded.png.



Firebase Storage Native API Example:



var fs = require("tns-core-modules/file-system");

// let's first determine where we'll create the file using the 'file- system' module
var documents = fs.knownFolders.documents();
var logoPath = documents.path + "/telerik-logo-downloaded.png";

// this will create or overwrite a local file in the app's documents folder
var localLogoFile = documents.getFile("telerik-logo-downloaded.png");

// now download the file with either of the options below:
firebase.storage.downloadFile({
bucket: 'gs://n-plugin-test.appspot.com',
remoteFullPath: 'uploads/images/telerik-logo-uploaded.png',
localFile: fs.File.fromPath(logoPath),
localFullPath: logoPath
}).then(
function (uploadedFile) {
console.log("File downloaded to the requested location");
},
function (error) {
console.log("File download error: " + error);
}
);


When there's a change(e.g. user uploads a new photo), I will download the photo with the Firebase Storage Native API and overwrite the existing one.



var localLogoFile = documents.getFile("telerik-logo-downloaded.png");


this code above should overwrite the local file if it's existing.



In the result, the new photo will be shown on iOS but not Android. For Android, it's still the old photo.



May anyone help? Thank you~










share|improve this question















I'm new to NativeScript.



I'm using nativescript-plugin-firebase to download the photo of the user and save it into /data/user/0/{APP_ID}/files/telerik-logo-downloaded.png.



Firebase Storage Native API Example:



var fs = require("tns-core-modules/file-system");

// let's first determine where we'll create the file using the 'file- system' module
var documents = fs.knownFolders.documents();
var logoPath = documents.path + "/telerik-logo-downloaded.png";

// this will create or overwrite a local file in the app's documents folder
var localLogoFile = documents.getFile("telerik-logo-downloaded.png");

// now download the file with either of the options below:
firebase.storage.downloadFile({
bucket: 'gs://n-plugin-test.appspot.com',
remoteFullPath: 'uploads/images/telerik-logo-uploaded.png',
localFile: fs.File.fromPath(logoPath),
localFullPath: logoPath
}).then(
function (uploadedFile) {
console.log("File downloaded to the requested location");
},
function (error) {
console.log("File download error: " + error);
}
);


When there's a change(e.g. user uploads a new photo), I will download the photo with the Firebase Storage Native API and overwrite the existing one.



var localLogoFile = documents.getFile("telerik-logo-downloaded.png");


this code above should overwrite the local file if it's existing.



In the result, the new photo will be shown on iOS but not Android. For Android, it's still the old photo.



May anyone help? Thank you~







javascript android filesystems nativescript firebase-storage






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 9 at 14:17









Frank van Puffelen

220k25361387




220k25361387










asked Nov 9 at 10:54









Felicia

304




304












  • hello @felicia, may I ask how do you load the photo?
    – vann_goh
    Nov 9 at 13:20










  • Thanks for replying @vann_goh, this way img.src = logoPath, is there any problem?
    – Felicia
    Nov 9 at 13:22










  • may you try to change the way you load the photo as I comment below? Tell me if it works ;)
    – vann_goh
    Nov 9 at 13:26










  • Oh yeah!!! Thank you soooo much @vann_goh!!! It works
    – Felicia
    Nov 9 at 14:27


















  • hello @felicia, may I ask how do you load the photo?
    – vann_goh
    Nov 9 at 13:20










  • Thanks for replying @vann_goh, this way img.src = logoPath, is there any problem?
    – Felicia
    Nov 9 at 13:22










  • may you try to change the way you load the photo as I comment below? Tell me if it works ;)
    – vann_goh
    Nov 9 at 13:26










  • Oh yeah!!! Thank you soooo much @vann_goh!!! It works
    – Felicia
    Nov 9 at 14:27
















hello @felicia, may I ask how do you load the photo?
– vann_goh
Nov 9 at 13:20




hello @felicia, may I ask how do you load the photo?
– vann_goh
Nov 9 at 13:20












Thanks for replying @vann_goh, this way img.src = logoPath, is there any problem?
– Felicia
Nov 9 at 13:22




Thanks for replying @vann_goh, this way img.src = logoPath, is there any problem?
– Felicia
Nov 9 at 13:22












may you try to change the way you load the photo as I comment below? Tell me if it works ;)
– vann_goh
Nov 9 at 13:26




may you try to change the way you load the photo as I comment below? Tell me if it works ;)
– vann_goh
Nov 9 at 13:26












Oh yeah!!! Thank you soooo much @vann_goh!!! It works
– Felicia
Nov 9 at 14:27




Oh yeah!!! Thank you soooo much @vann_goh!!! It works
– Felicia
Nov 9 at 14:27












2 Answers
2






active

oldest

votes

















up vote
0
down vote



accepted










I guess your problem is the way you load the imageSource.



It should already overwrite the file, try this



img.src = imageSource.fromFile(logoPath)


instead of



img.src = logoPath


Hope it helps! Cheers!






share|improve this answer




























    up vote
    0
    down vote













    With Android image won't be refreshed if it's the same url again. Try setting the image source to null and then set it back to your path again.






    share|improve this answer





















    • I found the answer above, also I wish I could upvote your answer as well! Thank you sooo much @Manoj
      – Felicia
      Nov 10 at 4:48











    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53224334%2fnativescript-file-system-overwrite-not-working-on-android%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote



    accepted










    I guess your problem is the way you load the imageSource.



    It should already overwrite the file, try this



    img.src = imageSource.fromFile(logoPath)


    instead of



    img.src = logoPath


    Hope it helps! Cheers!






    share|improve this answer

























      up vote
      0
      down vote



      accepted










      I guess your problem is the way you load the imageSource.



      It should already overwrite the file, try this



      img.src = imageSource.fromFile(logoPath)


      instead of



      img.src = logoPath


      Hope it helps! Cheers!






      share|improve this answer























        up vote
        0
        down vote



        accepted







        up vote
        0
        down vote



        accepted






        I guess your problem is the way you load the imageSource.



        It should already overwrite the file, try this



        img.src = imageSource.fromFile(logoPath)


        instead of



        img.src = logoPath


        Hope it helps! Cheers!






        share|improve this answer












        I guess your problem is the way you load the imageSource.



        It should already overwrite the file, try this



        img.src = imageSource.fromFile(logoPath)


        instead of



        img.src = logoPath


        Hope it helps! Cheers!







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 9 at 13:25









        vann_goh

        221110




        221110
























            up vote
            0
            down vote













            With Android image won't be refreshed if it's the same url again. Try setting the image source to null and then set it back to your path again.






            share|improve this answer





















            • I found the answer above, also I wish I could upvote your answer as well! Thank you sooo much @Manoj
              – Felicia
              Nov 10 at 4:48















            up vote
            0
            down vote













            With Android image won't be refreshed if it's the same url again. Try setting the image source to null and then set it back to your path again.






            share|improve this answer





















            • I found the answer above, also I wish I could upvote your answer as well! Thank you sooo much @Manoj
              – Felicia
              Nov 10 at 4:48













            up vote
            0
            down vote










            up vote
            0
            down vote









            With Android image won't be refreshed if it's the same url again. Try setting the image source to null and then set it back to your path again.






            share|improve this answer












            With Android image won't be refreshed if it's the same url again. Try setting the image source to null and then set it back to your path again.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 9 at 14:16









            Manoj

            2,7791916




            2,7791916












            • I found the answer above, also I wish I could upvote your answer as well! Thank you sooo much @Manoj
              – Felicia
              Nov 10 at 4:48


















            • I found the answer above, also I wish I could upvote your answer as well! Thank you sooo much @Manoj
              – Felicia
              Nov 10 at 4:48
















            I found the answer above, also I wish I could upvote your answer as well! Thank you sooo much @Manoj
            – Felicia
            Nov 10 at 4:48




            I found the answer above, also I wish I could upvote your answer as well! Thank you sooo much @Manoj
            – Felicia
            Nov 10 at 4:48


















             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53224334%2fnativescript-file-system-overwrite-not-working-on-android%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Schultheiß

            Verwaltungsgliederung Dänemarks

            Liste der Kulturdenkmale in Wilsdruff