com.jeesuite.filesystem.sdk.fdfs.codec.FileIdDecoder Maven / Gradle / Ivy
/**
*
*/
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);
}
}