Skip to content

Some utils and examples about how to operate remote files through smb in java

License

Notifications You must be signed in to change notification settings

EvanLeung08/eshare-smb-client-in-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Getting Started

An API adapter provides some base operation for new learner to study how to use SMBJ and Jcifs in your project.

  • Smbj only supports SMB2 above version
  • Jcifs only supports SMB1

Features:

  • Supports SMB2.0 above CRUD operation by default
  • Supports SMB1.0 CRUD operation by input smbVersion:1.0 field in api request parameters

smbj-api-adapter

Core Flow

Below diagram is generated by ChatGPT

API Doc

http://localhost:8080/swagger-ui/index.html

How To Run

1.SMB Upload

Change the value based on your actual needs

For SMB1.0 , please add one more parameter "smbVersion":"1.0"

{
    "remoteHost": "192.168.50.69",
    "shareName": "LANdrive",
    "domain": null,
    "account": "user",
    "password": "123456",
    "remoteFolder": "test/",
    "localFilePath": "/Users/evan/Downloads/Untitled video (4).mp4"
}

File in remote folder

2.SMB Download

Change the value based on your actual needs

For SMB1.0 , please add one more parameter "smbVersion":"1.0"

{
    "remoteHost": "192.168.50.69",
    "shareName": "LANdrive",
    "domain": null,
    "account": "user",
    "password": "123456",
    "remoteFolder": "test/",
    "localFolder": "/Users/evan/Downloads/",
    "filePattern": ".*\\.mp4$",
    "fileExtension": ".d",
    "needRename": true
}

File in local folder

The file will be renamed to ".d" after download successfully by default

The file has been downloaded to local storage and updated the modified time

3.SMB Delete

Change the value based on your actual needs

For SMB1.0 , please add one more parameter "smbVersion":"1.0"

{
    "remoteHost": "192.168.50.69",
    "shareName": "LANdrive",
    "domain": null,
    "account": "user",
    "password": "123456",
    "remoteFolder": "test/",
    "filePattern": "*"
}

File has been removed from remote folder

The file has been removed from remote folder

4.SMB Search

Change the value based on your actual needs

For SMB1.0 , please add one more parameter "smbVersion":"1.0"

{
     "remoteHost": "192.168.50.69",
     "shareName": "LANdrive",
     "domain": null,
     "account": "user",
     "password": "123456",
     "remoteFolder": "test/",
     "filePattern": ".*\\.mp4$"
 }

File list in the response

The file will show in API response

5.SMB Rename

Change the value based on your actual needs

For SMB1.0 , please add one more parameter "smbVersion":"1.0"

{
    "remoteHost": "192.168.50.69",
    "shareName": "LANdrive",
    "domain": null,
    "account": "user",
    "password": "123456",
    "remoteFolder": "test/",
    "filePattern": ".*\\.mp4$",
    "prefix": "test_",
    "suffix": ".d",
    "newFileName": "after"
}

File has been renamed successfully

Before

After

About

Some utils and examples about how to operate remote files through smb in java

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages