swaechter / smbjwrapper Goto Github PK
View Code? Open in Web Editor NEWA modern object orientated library for Samba SMB
Home Page: https://github.com/swaechter/smbjwrapper
License: MIT License
A modern object orientated library for Samba SMB
Home Page: https://github.com/swaechter/smbjwrapper
License: MIT License
Bug description
Hi @swaechter, there's a newer version of the smbj library that fixes some bugs caused by the update to Java like this, is there any plans to update this library?
Additional information
Hi,
I found a bug in rename directory. When I was working on our application I found out the rename doesnt work. First I found out that PATH_SEPARATOR is slash instead of backslash. I put the path as backslash and getParentPath returned always / (isRoot returned true). and the renameTo function requires backslashes otherwise the rename failed as ACCESS_DENIED. Try to simulate it with more nested folders. Maybe its due our infrastructure I am not sure. We are running on DFS
Kind regards,
Jozef
Write a test case for listFiles(Predicate<SharedItem> searchPredicate, boolean searchRecursive)
- at the moment this method is not covered.
The listFiles
methods return files and directories, so the name is missleading (Thus rename the methods).
Provide a method isHidden
to check if a file/directory is hidden or not: hierynomus/smbj#267
Hi thanks for your work.
I have a task to get a list of all disks available on the server, but as far as I understand the SMBJ does not provide such opportunities, will your library help in this matter?
The method SmbItem.isRootPath
returns true for the first subdirectory as directory path. A quick fix would be to check if the path is empty, but this won't work on DFS share.
In addition the method (and maybe other methods like getRootPath
) should move to the SmbDirectory
class. It's not possible to check if a file is the root path (Maybe it's interesting to know if the file is IN the root directory)
Provide a listFiles method with no arguments, so we can fetch directories and files together and don't have to use getDirectories
+ getFiles
+ merge the list
Add a SharedDirectory.listFiles(String searchPattern, boolean recursiveList)
method to [recursively] list files in a directory
@JozefDropco Are you in favor of a regex or a boolean supplier method (So you are able to filter more than file names, e.g. file size)? Both?
com.hierynomu com.hierynomus.ms smb2.SMB ApiException: STATUS_ACCESS_DENIED (0xc0000022): SetInfo failed for SMB2FileId file rename. rename file
Hi,
in our environment we are connecting to multiple diskshares and we dont know upfront how many of them will be. Also creation of DiskShare in constructor is an expensive operation and might fail due current connection issue. DiskShare should be created on demand once its needed by SharedFile or SharedDirectory. Also the connection should be able to reconnect or created on demand so the connection can be reused by parallel requests
Add a SharedFile|SharedDirectory.rename(String newFilename, boolean overrideExisting)
method to rename items.
Please support rang read and rang write.
This is very important, for example, the player plays the video switch progress
Make the library Java 9+ ready while keeping the Java 8 support.
(I only did Java 9+ module libraries, so if anyone can share a Java 8/9+ solution, that would be great).
Move the documentation to an own & versioned documentation page (Not the README.md).
Fix the exception signature of the SharedConnection.close()
method - use IOException instead of Exception
It should be possible to append content to existing files (and not overwrite them)
@JozefDropco Was your feature pull request released with the 0.9.1 release or is it still pending?
Hi! I'm testing your wrapper and all examples work well. Really great wrapper!
But the last example (Download to an output stream) is not working:
[main] INFO com.hierynomus.smbj.session.Session - Logging off session 4398650490985 from host vm.test.com
[main] INFO com.hierynomus.smbj.connection.Connection - Closed connection to vm.test.com
[Packet Reader for vm.test.com] INFO com.hierynomus.smbj.transport.PacketReader - Thread[Packet Reader for vm.test.com,5,main] stopped.
com.hierynomus.mssmb2.SMBApiException: STATUS_ACCESS_DENIED(3221225506/3221225506): Create failed for test.txt
at com.hierynomus.smbj.share.Share.receive(Share.java:342)
at com.hierynomus.smbj.share.Share.sendReceive(Share.java:322)
at com.hierynomus.smbj.share.Share.createFile(Share.java:135)
at com.hierynomus.smbj.share.DiskShare.createFileAndResolve(DiskShare.java:79)
at com.hierynomus.smbj.share.DiskShare.open(DiskShare.java:69)
at com.hierynomus.smbj.share.DiskShare.openFile(DiskShare.java:144)
at ch.swaechter.smbjwrapper.SharedFile.getInputStream(SharedFile.java:53)
at Main.main(Main.java:25)
Problem is here:
InputStream inputStream = sharedFile.getInputStream();
Any ideas?
Note: I use smbj version 0.8.0
It would be nice to have two additional methods in your SmbOutputStream
:
@Override
public void write(byte[] b) throws IOException {
outputStream.write(b, 0, b.length);
}
@Override
public void write(byte[] b, int off, int len) throws IOException {
outputStream.write(b, off, len);
}
Provide a possibility to pass a custom SMB config to the shared connection.
Provide a method isWritable
to check if the file/directory path is writable or not.
Add a SharedDirectory.ensureExists()
method that ensures the existence of the directory (Creation if required).
Hi,
there is bug in your example code for custom SMBJ config.
SmbConfig smbConfig = SmbConfig.builder().withSoTimeout(3000).build(); AuthenticationContext authenticationContext = new AuthenticationContext("USERNAME", "PASSWORD".toCharArray(), "DOMAIN"**, smbConfig**); try (SharedConnection sharedConnection = new SharedConnection("127.0.0.1", "Share", authenticationContext)) { // Do your work }
smbConfig should be passed to new SharedConnection instead
Kind regards,
Jozef
I have forced to change SMB2ShareAccess.ALL
to EnumSet.of(SMB2ShareAccess.FILE_SHARE_READ, SMB2ShareAccess.FILE_SHARE_DELETE)
when opening the sourceFile
because of impossibility to remove the sourceFile
after copying which leads to STATUS_SHARING_VIOLATION (0xc0000043)
public void copyFileViaServerSideCopy(SmbFile destinationSmbFile) throws Buffer.BufferException, TransportException {
try (
File sourceFile = getDiskShare().openFile(getPath(), EnumSet.of(AccessMask.GENERIC_READ), null, SMB2ShareAccess.ALL, SMB2CreateDisposition.FILE_OPEN, null);
File destinationFile = getDiskShare().openFile(destinationSmbFile.getPath(), EnumSet.of(AccessMask.GENERIC_ALL), null, SMB2ShareAccess.ALL, SMB2CreateDisposition.FILE_OVERWRITE_IF, null);
) {
sourceFile.remoteCopyTo(destinationFile);
}
}
Hi! I see, that there is no way to retreive file/directory information using only wrapper.
It would be great to create these methods for _FILE_ALL_INFORMATION or _FILE_BASIC_INFORMATION
In smbj exist methods like public FileAllInformation getFileInformation... but it is inconvenient to use these methods.
What about it?
Sincerely,
Alex
Hi, can you please add this feature into your wrapper. We would like to use this instead maintaining our own codebase for handling connections of SMBJ
Thanks and kind regards,
Jozef
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.