Search in sources :

Example 1 with FTPStorageFactory

use of net.yacy.grid.io.assets.FTPStorageFactory in project yacy_grid_mcp by yacy.

the class MultiProtocolURL method get.

public byte[] get(final ClientIdentification.Agent agent, final String username, final String pass) throws IOException {
    if (isFile())
        return read(new FileInputStream(getFSFile()));
    if (isSMB())
        return read(new SmbFileInputStream(getSmbFile()));
    if (isFTP()) {
        FTPStorageFactory client = new FTPStorageFactory(this.host, this.port < 0 ? 21 : this.port, username, pass, false);
        Asset<byte[]> asset = client.getStorage().load(this.path);
        return asset.getPayload();
    }
    if (isHTTP() || isHTTPS()) {
        // TODO: add agent, user and pass
        return ClientConnection.load(this.toString());
    }
    return null;
}
Also used : SmbFileInputStream(jcifs.smb.SmbFileInputStream) FTPStorageFactory(net.yacy.grid.io.assets.FTPStorageFactory) FileInputStream(java.io.FileInputStream) SmbFileInputStream(jcifs.smb.SmbFileInputStream)

Example 2 with FTPStorageFactory

use of net.yacy.grid.io.assets.FTPStorageFactory in project yacy_grid_mcp by yacy.

the class MultiProtocolURL method getInputStream.

public InputStream getInputStream(final ClientIdentification.Agent agent, final String username, final String pass) throws IOException {
    if (isFile())
        return new BufferedInputStream(new FileInputStream(getFSFile()));
    if (isSMB())
        return new BufferedInputStream(new SmbFileInputStream(getSmbFile()));
    if (isFTP()) {
        FTPStorageFactory client = new FTPStorageFactory(this.host, this.port < 0 ? 21 : this.port, username, pass, false);
        Asset<byte[]> asset = client.getStorage().load(this.path);
        return new ByteArrayInputStream(asset.getPayload());
    }
    if (isHTTP() || isHTTPS()) {
        // TODO: add agent, user and pass
        return new ByteArrayInputStream(ClientConnection.load(this.toString()));
    }
    return null;
}
Also used : SmbFileInputStream(jcifs.smb.SmbFileInputStream) BufferedInputStream(java.io.BufferedInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) FTPStorageFactory(net.yacy.grid.io.assets.FTPStorageFactory) FileInputStream(java.io.FileInputStream) SmbFileInputStream(jcifs.smb.SmbFileInputStream)

Aggregations

FileInputStream (java.io.FileInputStream)2 SmbFileInputStream (jcifs.smb.SmbFileInputStream)2 FTPStorageFactory (net.yacy.grid.io.assets.FTPStorageFactory)2 BufferedInputStream (java.io.BufferedInputStream)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1