示例#1
0
        public async Task <string> DownloadAndExtractAsync()
        {
            var req = RequestEngine.CreateClient(_AccessConfig);

            var gzipFilePath = await RequestEngine.DownloadFileAsync(req, XmlFileUrl, _AccessConfig.DownloadDirectory);

            var unzipFilePath = await GZipUtils.DecompressAsync(new FileInfo(gzipFilePath));

            return(unzipFilePath);
        }
示例#2
0
        public async Task <string> DownloadAndExtractAsync(string xmlUrlPath, string saveFilePath = null)
        {
            var req = RequestEngine.CreateClient(_AccessConfig);

            var saveDirectoryPath = _AccessConfig.DownloadDirectory;

            if (!string.IsNullOrEmpty(saveFilePath))
            {
                saveDirectoryPath = Path.GetDirectoryName(saveFilePath);
            }

            var gzipFilePath = await RequestEngine.DownloadFileToDirectoryAsync(req, xmlUrlPath, saveDirectoryPath);

            var unzipFilePath = await GZipUtils.DecompressAsync(new FileInfo(gzipFilePath), saveFilePath);

            return(unzipFilePath);
        }
    public static Message ParseFromBytes(byte[] headerData, byte[] bodyData)
    {
        MessageHeader header = MessageHeader.ParseFromBytes(headerData);
        //Debug.Log("parseFromBytes. MessageType: " + header.getMessageType() + " compressed: " + header.isCompressed());
        MessageBody body = null;

        if (header.IsCompressed)
        {
            byte[] dataUncompressed = GZipUtils.Decompress(bodyData);
            body = new MessageBody(dataUncompressed);
        }
        else
        {
            body = new MessageBody(bodyData);
        }
        return(new Message(header, body));
    }
    /// Create a message.
    /// Automatic compression will be performed for large messages
    public static Message Create(int type, byte[] bodyData)
    {
        int bodySize = bodyData.Length;

        MessageHeader header = null;
        MessageBody   body   = null;

        if (bodySize > MESSAGE_COMPRESS_THRESHOLD_KB)  //check if body should be compressed
        {
            byte[] compressedBodyData = GZipUtils.Compress(bodyData);
            int    compressedBodySize = compressedBodyData.Length;
            header = new MessageHeader(type, compressedBodySize, true);
            body   = new MessageBody(compressedBodyData);
        }
        else     //uncompressed
        {
            header = new MessageHeader(type, bodySize, false);
            body   = new MessageBody(bodyData);
        }
        return(new Message(header, body));
    }
示例#5
0
 public static bool ZipFile(string fileToZip, string zipedFile)
 {
     return(GZipUtils.ZipFile(fileToZip, zipedFile, null));
 }