[jcifs] Binary File Upload to Multiple Servers?

Michael B Allen mba2000 at ioplex.com
Sat Sep 6 05:15:55 EST 2003

> Hi,
> I want upload binary files to multiple Win32 or Linux machines (servers).
> The file transfer should support resume in case of breaks.
> I want to use Java on Linux  (client). Would JCIFS be helpful in this
> case?

JCIFS probably does this sort of thing better than any other CIFS client.

> I briefly skimmed through the docs and I think its possible. If any body
> has
> used jcifs in a similar scenario pls let me know.
> A few features I want is:
>   a.. File Transfer Resumption - To continue copying from a particular
> point

The off parameter SmbFileOutputStream.write() will skip to that offset.
Same for SmbFileInputStream.read().

> in the file, when failures occur.
>   b.. Source File Completion Checking - To ensure that files do not get
> copied (in the source location) that are still being written.

Use SmbFile.FILE_NO_SHARE to lock the file. Also, jCIFS operates very well
in a threaded environment. I recommend using 1 VM to do all of the work so
that you can better coordinate each transfer (and possibly eliminate the
need for FILE_NO_SHARE shareAccess altogether).

>   c.. Source File Compression

Wrap SmbFileOutputStream with java.util.zip.ZipOutputStream maybe?

>   d.. Multiple Destination Directories - To transfer the same source
> file(s)

You'll have transfer each separately.

> to multiple destinations.
>   e.. Destination File Completion Renaming - To ensure files do not get
> finalized until the copy has completed


>   f.. Destination File Existence Checking - To check whether the file
> already exists (in the destination location), and accordingly either do no
> copy, and overwrite it (default)

SmbFile.exists(). One thing to watch out for however is that file
attributes (e.g. length()) are cached briefly. So if you create two
SmbFiles that point to the same physical file and you change the
attributes of one and then quickly view that attribute using the other,
the second will not have updated yet. So take care to coordinate your
threads properly so that you never have two SmbFile instances to the same
file. Or if you are using separate VMs/machines you may want to turn off
caching (see the API documentation) but you will take a significant
perfomance hit for certain operations.

> I strictly want to use Java on Linux (client requirement).

No problem.

More information about the jcifs mailing list