Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="paramList">
        /// 1,IPEndPoint    IPEndPoint-->the storage IPEndPoint
        /// 2,string groupName
        /// 3,string fileName
        /// </param>
        /// <returns></returns>
        public override FDFSRequest GetRequest(params object[] paramList)
        {
            if (paramList.Length != 3)
            {
                throw new FDFSException("param count is wrong");
            }
            IPEndPoint endPoint = (IPEndPoint)paramList[0];

            string groupName = (string)paramList[1];
            string fileName  = (string)paramList[2];

            DELETE_FILE result = new DELETE_FILE();

            result.Connection = ConnectionManager.GetStorageConnection(endPoint);

            if (groupName.Length > Consts.FDFS_GROUP_NAME_MAX_LEN)
            {
                throw new FDFSException("groupName is too long");
            }

            long length = Consts.FDFS_GROUP_NAME_MAX_LEN +
                          fileName.Length;

            byte[] bodyBuffer      = new byte[length];
            byte[] groupNameBuffer = Util.StringToByte(groupName);
            byte[] fileNameBuffer  = Util.StringToByte(fileName);

            Array.Copy(groupNameBuffer, 0, bodyBuffer, 0, groupNameBuffer.Length);
            Array.Copy(fileNameBuffer, 0, bodyBuffer, Consts.FDFS_GROUP_NAME_MAX_LEN, fileNameBuffer.Length);

            result.Body   = bodyBuffer;
            result.Header = new FDFSHeader(length, Consts.STORAGE_PROTO_CMD_DELETE_FILE, 0);
            return(result);
        }
Example #2
0
        public override FDFSRequest GetRequest(params object[] paramList)
        {
            if (paramList.Length != 3)
            {
                throw new FDFSException("param count is wrong");
            }
            IPEndPoint  endPoint   = (IPEndPoint)paramList[0];
            string      groupName  = (string)paramList[1];
            string      fileName   = (string)paramList[2];
            DELETE_FILE deleteFile = new DELETE_FILE
            {
                ConnectionType = FDFSConnectionType.StorageConnection,
                EndPoint       = endPoint
            };
            var groupNameByteCount = Util.StringByteCount(groupName);

            if (groupNameByteCount > 16)
            {
                throw new FDFSException("groupName is too long");
            }
            var fileNameByteCount = Util.StringByteCount(fileName);
            int length            = 16 + fileNameByteCount;

            deleteFile.SetBodyBuffer(length);
            Util.StringToByte(groupName, deleteFile.BodyBuffer, 0, groupNameByteCount);
            Util.StringToByte(fileName, deleteFile.BodyBuffer, 16, fileNameByteCount);
            deleteFile.Header = new FDFSHeader(length, FDFSConstants.STORAGE_PROTO_CMD_DELETE_FILE, 0);
            return(deleteFile);
        }
Example #3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="paramList">
        /// 1,IPEndPoint    IPEndPoint-->the storage IPEndPoint
        /// 2,string groupName
        /// 3,string fileName
        /// </param>
        /// <returns></returns>
        public override FDFSRequest GetRequest(params object[] paramList)
        {
            if (paramList.Length != 3)
                throw new FDFSException("param count is wrong");
            IPEndPoint endPoint = (IPEndPoint)paramList[0];
            
            string groupName = (string)paramList[1];
            string fileName = (string)paramList[2];

            DELETE_FILE result = new DELETE_FILE();
            result.Connection = ConnectionManager.GetStorageConnection(endPoint);

            if (groupName.Length > Consts.FDFS_GROUP_NAME_MAX_LEN)
                throw new FDFSException("groupName is too long");

            long length = Consts.FDFS_GROUP_NAME_MAX_LEN +
                fileName.Length;
            byte[] bodyBuffer = new byte[length];
            byte[] groupNameBuffer = Util.StringToByte(groupName);
            byte[] fileNameBuffer = Util.StringToByte(fileName);
            
            Array.Copy(groupNameBuffer, 0, bodyBuffer, 0, groupNameBuffer.Length);
            Array.Copy(fileNameBuffer, 0, bodyBuffer, Consts.FDFS_GROUP_NAME_MAX_LEN, fileNameBuffer.Length);

            result.Body = bodyBuffer;
            result.Header = new FDFSHeader(length, Consts.STORAGE_PROTO_CMD_DELETE_FILE, 0);
            return result;
        }
Example #4
0
        public override FDFSRequest GetRequest(params object[] paramList)
        {
            if (paramList.Length != 3)
            {
                throw new FDFSException("param count is wrong");
            }
            IPEndPoint  endPoint   = (IPEndPoint)paramList[0];
            string      input      = (string)paramList[1];
            string      str2       = (string)paramList[2];
            DELETE_FILE deleteFile = new DELETE_FILE
            {
                ConnectionType = 1,
                EndPoint       = endPoint
            };

            if (input.Length > 0x10)
            {
                throw new FDFSException("groupName is too long");
            }
            long length = 0x10 + str2.Length;

            byte[] destinationArray = new byte[length];
            byte[] sourceArray      = Util.StringToByte(input);
            byte[] buffer3          = Util.StringToByte(str2);
            Array.Copy(sourceArray, 0, destinationArray, 0, sourceArray.Length);
            Array.Copy(buffer3, 0, destinationArray, 0x10, buffer3.Length);
            deleteFile.Body   = destinationArray;
            deleteFile.Header = new FDFSHeader(length, 12, 0);
            return(deleteFile);
        }
Example #5
0
 /// <summary>
 /// 删除文件
 /// </summary>
 /// <param name="groupName">组名</param>
 /// <param name="fileName">文件名</param>
 public static void RemoveFile(string groupName, string fileName)
 {
     fileName = GetFileName(groupName, fileName);
     using (var trackerRequest = QUERY_UPDATE.CreateRequest(groupName, fileName))
     {
         var trackerResponse = new QUERY_UPDATE.Response(trackerRequest.GetTrackerResponse());
         var storeEndPoint   = new IPEndPoint(IPAddress.Parse(trackerResponse.IpStr), trackerResponse.Port);
         using (var storageReqeust = DELETE_FILE.CreateRequest(storeEndPoint, groupName, fileName))
         {
             byte[] responseByte = storageReqeust.GetStorageResponse();
             string result       = Util.ByteToString(responseByte).TrimEnd('\0');
         }
     }
 }