/// <summary>EncodeBody
        /// </summary>
        public override byte[] EncodeBody(ClusterConfiguration configuration)
        {
            var groupNameBuffer = EndecodeUtil.EncodeGroupName(GroupName, configuration.Charset);
            //文件偏移量
            var offsetBuffer = EndecodeUtil.EncodeLong(Offset);
            //下载文件的大小,全部下载用0
            var byteSizeBuffer = EndecodeUtil.EncodeLong(ByteSize);
            //文件FileId数组
            var fileIdBuffer = EndecodeUtil.EncodeString(FileId, configuration.Charset);

            //long length = Consts.FDFS_PROTO_PKG_LEN_SIZE + Consts.FDFS_PROTO_PKG_LEN_SIZE + Consts.FDFS_GROUP_NAME_MAX_LEN + FileId.Length;

            return(ByteUtil.Combine(offsetBuffer, byteSizeBuffer, groupNameBuffer, fileIdBuffer));
        }
예제 #2
0
        ///// <summary>使用流传输
        ///// </summary>
        //public override bool StreamRequest => true;

        /// <summary>EncodeBody
        /// </summary>
        public override byte[] EncodeBody(FastDFSOption option)
        {
            //1.StorePathIndex

            //2.文件长度
            var fileSizeBuffer = EndecodeUtil.EncodeLong(InputStream.Length);

            //3.扩展名
            byte[] extBuffer = EndecodeUtil.EncodeFileExt(FileExt, option.Charset);
            //4.文件数据,这里不写入
            //int lenth = 1 + Consts.FDFS_PROTO_PKG_LEN_SIZE + Consts.FDFS_FILE_EXT_NAME_MAX_LEN;

            var bodyBuffer = new List <byte>
            {
                StorePathIndex
            };

            bodyBuffer.AddRange(fileSizeBuffer);
            bodyBuffer.AddRange(extBuffer);
            return(bodyBuffer.ToArray());
        }
예제 #3
0
        ///// <summary>是否流请求
        ///// </summary>
        //public override bool StreamRequest => true;

        /// <summary>EncodeBody
        /// </summary>
        public override byte[] EncodeBody(ClusterConfiguration configuration)
        {
            //文件名长度数组
            var masterFileIdLenBuffer = EndecodeUtil.EncodeLong((long)MasterFileId.Length);
            //文件长度数组
            var fileSizeBuffer = EndecodeUtil.EncodeLong(InputStream.Length);

            //从文件前缀名数据
            var prefixBuffer = EndecodeUtil.EncodePrefix(Prefix, configuration.Charset);
            var extBuffer    = EndecodeUtil.EncodeFileExt(FileExt, configuration.Charset);
            //主文件Id
            var masterFileIdBuffer = EndecodeUtil.EncodeString(MasterFileId, configuration.Charset);


            //2个长度,主文件FileId数组长度,文件长度
            //long length = 2 * Consts.FDFS_PROTO_PKG_LEN_SIZE + Consts.FDFS_FILE_PREFIX_MAX_LEN + Consts.FDFS_FILE_EXT_NAME_MAX_LEN + masterFileIdBuffer.Length;

            return(ByteUtil.Combine(masterFileIdLenBuffer, fileSizeBuffer, prefixBuffer, extBuffer, masterFileIdBuffer));

            //文件内容
            //Array.Copy(ContentBytes, 0, bodyBuffer, offset, ContentBytes.Length);
        }
예제 #4
0
        ///// <summary>使用流传输
        ///// </summary>
        //public override bool StreamRequest => true;

        /// <summary>EncodeBody
        /// </summary>
        public override byte[] EncodeBody(ClusterConfiguration configuration)
        {
            //1.StorePathIndex

            //2.文件长度

            //var fileSizeBuffer = EndecodeUtil.EncodeLong(InputStream.Length);
            byte[] fileSizeBuffer;
            if (InputStream != null)
            {
                fileSizeBuffer = EndecodeUtil.EncodeLong(InputStream.Length);
            }
            else
            {
                fileSizeBuffer = EndecodeUtil.EncodeLong(Content.Length);
            }


            //3.扩展名
            byte[] extBuffer = EndecodeUtil.EncodeFileExt(FileExt, configuration.Charset);
            //4.文件数据,这里不写入
            //int lenth = 1 + Consts.FDFS_PROTO_PKG_LEN_SIZE + Consts.FDFS_FILE_EXT_NAME_MAX_LEN;

            var bodyBuffer = new List <byte>
            {
                StorePathIndex
            };

            bodyBuffer.AddRange(fileSizeBuffer);
            bodyBuffer.AddRange(extBuffer);
            if (InputStream == null && Content != null)
            {
                bodyBuffer.AddRange(Content);
            }

            return(bodyBuffer.ToArray());
        }