Search in sources :

Example 1 with DownloadByteArray

use of com.github.tobato.fastdfs.domain.proto.storage.DownloadByteArray in project oner365-cloud by xiaozhao32.

the class FileFdfsClient method download.

/**
 * 下载文件
 *
 * @param fileUrl 文件url
 * @return byte[]
 */
@Override
public byte[] download(String fileUrl) {
    String group = fileUrl.substring(0, fileUrl.indexOf(PublicConstants.DELIMITER));
    String downloadPath = fileUrl.substring(fileUrl.indexOf(PublicConstants.DELIMITER) + 1);
    return fastFileStorageClient.downloadFile(group, downloadPath, new DownloadByteArray());
}
Also used : DownloadByteArray(com.github.tobato.fastdfs.domain.proto.storage.DownloadByteArray)

Example 2 with DownloadByteArray

use of com.github.tobato.fastdfs.domain.proto.storage.DownloadByteArray in project note by kebukeYi.

the class FastDFSClient method downloadFile.

/**
 * @param fileUrl 文件访问地址
 * @param file    文件保存路径
 * @author qbanxiaoli
 * @description 下载文件
 */
public static boolean downloadFile(String fileUrl, File file) {
    try {
        StorePath storePath = StorePath.parseFromUrl(fileUrl);
        byte[] bytes = fastFileStorageClient.downloadFile(storePath.getGroup(), storePath.getPath(), new DownloadByteArray());
        FileOutputStream stream = new FileOutputStream(file);
        stream.write(bytes);
    } catch (Exception e) {
        log.error(e.getMessage());
        return false;
    }
    return true;
}
Also used : DownloadByteArray(com.github.tobato.fastdfs.domain.proto.storage.DownloadByteArray) StorePath(com.github.tobato.fastdfs.domain.fdfs.StorePath)

Example 3 with DownloadByteArray

use of com.github.tobato.fastdfs.domain.proto.storage.DownloadByteArray in project Spring-Cloud by zhao-staff-officer.

the class FastDFSClient method downloadFile.

/**
 * 下载文件
 * @param fileUrl 文件url
 * @return
 */
public byte[] downloadFile(String fileUrl) {
    fileUrl = fileUrl.substring(fileUrl.indexOf("/", 7) + 1);
    String group = fileUrl.substring(0, fileUrl.indexOf("/"));
    String path = fileUrl.substring(fileUrl.indexOf("/") + 1);
    byte[] bytes = storageClient.downloadFile(group, path, new DownloadByteArray());
    return bytes;
}
Also used : DownloadByteArray(com.github.tobato.fastdfs.domain.proto.storage.DownloadByteArray)

Aggregations

DownloadByteArray (com.github.tobato.fastdfs.domain.proto.storage.DownloadByteArray)3 StorePath (com.github.tobato.fastdfs.domain.fdfs.StorePath)1