-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to list the local files and copy the local files into remote file server #675
Comments
If you take a look at the examples, you will see that share and path names in the SMB world are always separated with |
Share examples of how to connect the local system and read a list of files and copy the files into a remote server. |
|
I have tried using Java. I got a "Connection refused" error to connect the local(127.0.0.1) system. What is wrong with the below code. I don't know why authenticate is required to connect local desktop. My requirement is to connect the local desktop and list the files in particular folder using smbj. Code:
Error: |
My requirement is to list the files present in the folder in local desktop and then the listed file should be copied to a remote server.
|
The exception that you're getting indicates that locally you do not have an SMB server running. I think you should use the regular java.io.File to obtain the file from the local filesystem and then use a |
Did this answer your question? If so please close the ticket. |
Hello @hierynomus , I am a beginner, trying to copy some files from a local system to a remote server. I tried sftp, but that wont work in my case. Can you pin point me any code snippet that does this task using smb ? If this is what you were referring to, I have a few doubts in this snip :
what is a SHARENAME and FOLDER in this case ? |
Please raise ticket only if there is an issue, if you want to learn already
enough examples provided and lots of solved tickets which contains examples
you can use.
Thanks
R Ramarajan
…On Sun, 4 Sep, 2022, 10:17 pm Kaushik ramabhotla, ***@***.***> wrote:
Hello @hierynomus <https://github.com/hierynomus> ,
I am a beginner, trying to copy some files from a local system to a remote
server. I tried sftp, but that wont work in my case. Can you pin point me
any code snippet that does this task using smb ?
If this is what you were referring to, I have a few doubts in this snip :
SMBClient client = new SMBClient();
try (Connection connection = client.connect("SERVERNAME")) {
AuthenticationContext ac = new AuthenticationContext("USERNAME", "PASSWORD".toCharArray(), "DOMAIN");
Session session = connection.authenticate(ac);
// Connect to Share
try (DiskShare share = (DiskShare) session.connectShare("SHARENAME")) {
for (FileIdBothDirectoryInformation f : share.list("FOLDER", "*.TXT")) {
System.out.println("File : " + f.getFileName());
}
}
}
what is a SHARENAME and FOLDER in this case ?
—
Reply to this email directly, view it on GitHub
<#675 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AIJCEGSWYGGN5GM6J46MQALV4THDBANCNFSM5FJS4VCQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
I have tried to list the files in the local path using the library smbj, But unable to list & copy the local files to the remote file server. I am getting the error. Shared the code & error Log for reference.
My requirement is to change the "jcifs library" to "smbj library", the below sample code has been written for that.
Code:
SmbConfig cfg = SmbConfig.builder()
.withMultiProtocolNegotiate(true)
.withSigningRequired(false)
.withDfsEnabled(false)
.build();
Error:
[main] INFO com.hierynomus.smbj.connection.PacketEncryptor - Initialized PacketEncryptor with Cipher
[main] INFO com.hierynomus.smbj.connection.Connection - Successfully connected to: x.x.x.x
[main] INFO com.hierynomus.smbj.connection.SMBSessionBuilder - Successfully authenticated xxxx on x.x.x.x, session is 164423090532534600
com.hierynomus.mssmb2.SMBApiException: STATUS_BAD_NETWORK_NAME (0xc00000cc): Could not connect to \x.x.x.x/
at com.hierynomus.smbj.session.Session.connectTree(Session.java:151)
[main] INFO com.hierynomus.smbj.session.Session - Logging off session 164423090532534600 from host x.x.x.x
[main] INFO com.hierynomus.smbj.connection.Connection - Closed connection to x.x.x.x
[Packet Reader for x.x.x.x] INFO com.hierynomus.smbj.transport.tcp.direct.DirectTcpPacketReader - Thread[Packet Reader for x.x.x.x,5,main] stopped.
[main] INFO com.hierynomus.smbj.SMBClient - Going to close all remaining connections
The text was updated successfully, but these errors were encountered: