GithubHelp home page GithubHelp logo

swaechter / smbjwrapper Goto Github PK

View Code? Open in Web Editor NEW
35.0 6.0 6.0 174 KB

A modern object orientated library for Samba SMB

Home Page: https://github.com/swaechter/smbjwrapper

License: MIT License

Java 100.00%
smb samba java maven smbj jcifs cifs

smbjwrapper's Issues

Rename of directory doesnt work

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

SmbItem.isRootPath returns true for the first subdirectory

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

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 list file method

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?

getting issue while file rename

com.hierynomu com.hierynomus.ms smb2.SMB ApiException: STATUS_ACCESS_DENIED (0xc0000022): SetInfo failed for SMB2FileId file rename. rename file

Creation of Diskshare in SharedConnection

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

Make the library Java 9+ ready

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).

Append new content to files

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?

Issue with SharedFile.getInputStream()

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

[Proposal]: Add some methods to SmbOutputStream

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

Example code bug

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

Problem with copyFileViaServerSideCopy.

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

Add methods for retreiving File/Directory information

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

Feature request: add server side copy support

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.