All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jeesuite.filesystem.sdk.fdfs.codec.FileIdDecoder Maven / Gradle / Ivy

There is a newer version: 1.3.6
Show newest version
/**
 *
 */
package com.jeesuite.filesystem.sdk.fdfs.codec;

import com.jeesuite.filesystem.sdk.fdfs.FastdfsException;
import com.jeesuite.filesystem.sdk.fdfs.FileId;
import com.jeesuite.filesystem.sdk.fdfs.exchange.Replier;
import io.netty.buffer.ByteBuf;

import static com.jeesuite.filesystem.sdk.fdfs.FastdfsConstants.FDFS_GROUP_LEN;
import static com.jeesuite.filesystem.sdk.fdfs.FastdfsUtils.readString;

/**
 * 存储路径解码器
 *
 * @author liulongbiao
 */
public enum FileIdDecoder implements Replier.Decoder {

    INSTANCE;

    @Override
    public FileId decode(ByteBuf in) {
        int length = in.readableBytes();
        if (length <= FDFS_GROUP_LEN) {
            throw new FastdfsException("body length : " + length + ", is lte required group name length 16.");
        }
        String group = readString(in, FDFS_GROUP_LEN);
        String path = readString(in);
        return new FileId(group, path);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy