Write/upload a file using Samba/JCIFS issue (SmbAuthException: Access is denied)

前端 未结 2 481
孤城傲影
孤城傲影 2021-02-01 10:04

So I\'m trying to write a file from android device to windows shared folder. I\'m using latest version of JCIFS and code which displays available network shares works fine. So I

相关标签:
2条回答
  • 2021-02-01 10:36

    OMG!!! Solution was so simple!!! To access network which is not login/password protected and thus doesn't need any authorization is not NtlmPasswordAuthentication.ANONYMOUS BUT it is:

    NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(null, null, null);
    

    damn it wasn't that obvious!

    0 讨论(0)
  • 2021-02-01 10:44

    try with this code

     NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("",
                                username, password);
        sharepath = "smb://" + pathtosharefolder + test.txt;  
    
    
     sFile = new SmbFile(sharepath, auth);
        SmbFileOutputStream out = new SmbFileOutputStream(file, true);
        out.write(text.getBytes());
    

    Also check you have share the folder path that you are accessing. Also check it has given write permission to the folder

    0 讨论(0)
提交回复
热议问题