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());
}
}