[ 
https://issues.apache.org/jira/browse/CB-7487?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14137663#comment-14137663
 ] 

ASF GitHub Bot commented on CB-7487:
------------------------------------

Github user dpeacock commented on a diff in the pull request:

    https://github.com/apache/cordova-plugin-file/pull/81#discussion_r17681983
  
    --- Diff: src/android/LocalFilesystem.java ---
    @@ -579,6 +582,7 @@ public long writeToFileAtURL(LocalFilesystemURL 
inputURL, String data,
                        // Always close the output
                        out.close();
                 }
    +                   broadcastNewFile(inputURL);
    --- End diff --
    
    I agree with what you are saying here.  By the time we are in 
writeToFileAtURL it seems the file already exists, so I tried moving this logic 
to getFileForLocalURL.  In here I was checking if the file existed prior to 
creation, then broadcasting if it was created.  
    
    The results however were strange.  Though the files would appear, they 
would sometimes be 0 bytes in size.  Trying to debug the javascript portion 
always resulted in 0 byte files.
    
    I then tried re-testing the broadcast after the write (where it is in this 
commit) and it seems to work as expected.  I can't really explain why this 
occurring, perhaps you have some insight on this?  If not, I think it's 
probably best to leave the broadcast after every write to be safe.


> Writing a file doesn't show up on android MTP
> ---------------------------------------------
>
>                 Key: CB-7487
>                 URL: https://issues.apache.org/jira/browse/CB-7487
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android, Plugin File
>    Affects Versions: 3.4.0
>         Environment: Nexus 5 and Windows 7
>            Reporter: David Peacock
>            Assignee: Ian Clelland
>
> Using the file plug-in to write out a file works, but when you use MTP to 
> view the file when connected to USB on Windows the file doesn't show up.  
> The file shows up on the device or through adb.  Rebooting the device or 
> using things to refresh the MTP will have the file appear.  This was tested 
> on multiple Nexus 5 devices on multiple Windows 7 machines.
> Cordova should be broadcasting ACTION_MEDIA_SCANNER_SCAN_FILE on the file to 
> have it appear immediately.
> I will be submitting a pull request on the file plug-in for a fix I've tested 
> and confirmed that resolves this issue.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to