Share via

SMB2 File Upload Error in Java code for windows 2019

Anonymous
2022-08-10T19:13:17+00:00

Error while File Upload on windows server 2019 process using the SMB2 Java code:

We are getting below error:

com.hierynomus.mssmb2.SMBApiException: STATUS_BAD_NETWORK_NAME (0xc00000cc): Could not connect

When the value for - connectTree API is prefixing the the SMB server IP in Path -

 <serverip>\smb://<windowserverip>/d$/<ShareDrive>

Code:

SmbConfig cfg = SmbConfig.builder().build();

                      SMBClient client = new SMBClient(cfg);

                      Connection connection = client.connect(sambaIP);

                      AuthenticationContext ac = new AuthenticationContext(sambaUsername, sambaPass.toCharArray(), sambaDomain);

                      Session session = connection.authenticate(ac);

                                            System.out.printf("File uploaded Started------------>");

                      String uploadURL = uploadDestinationPath+"image-pdf"+"/" + mpFile1.getOriginalFilename();                                          

                      try (DiskShare share = (DiskShare) session.connectShare(uploadDestinationPath)) {

                        for (FileIdBothDirectoryInformation f : share.list(mpFile1.getOriginalFilename(), "*.*")) {

                              System.out.println("File Upload processing: ");

                            System.out.println("File : " + f.getFileName());

                        }

                    }

Windows for home | Other | Internet and connectivity

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. DaveM121 891.6K Reputation points Independent Advisor
    2022-08-10T19:45:35+00:00

    Hi Sachiee,

    I am Dave, I will help you with this.

    I apologize, Community is just a consumer forum, due to the scope of your question can you please post this question to our sister forum on Microsoft Q&A in the Server 2019 section (linked below)

    Over there you will have access to a host of IT Admins and 2019 experts and will get a knowledgeable and quick answer to this question.

    https://docs.microsoft.com/en-us/answers/topics...

    Was this answer helpful?

    0 comments No comments