2014-02-18 63 views
0

有谁知道如何压缩Ti.Utils.base64encode? 例如,我有这样的代码:如何压缩Ti.utils.base64encode并使用.Net方法解压缩?

uploadFile = Ti.Filesystem.getFile(pathFile, listing[_fileCtr].toString()); 
uploadFileName = listing[_fileCtr].toString(); 
encodedFile = Ti.Utils.base64encode(uploadFile.read()).toString(); 
//Send Image to .NET web service 

这是该方法在我的web服务,从钛解压缩图像(如果我可以压缩之前我的形象):

static byte[] Decompress(byte[] input) 
{ 
    using (MemoryStream output = new MemoryStream(input)) 
    { 
    using (GZipStream zip = new GZipStream(output, CompressionMode.Decompress)) 
    { 
    List<byte> bytes = new List<byte>(); 
    int b = zip.ReadByte(); 
    while (b != -1) 
    { 
    bytes.Add((byte)b); 
    b = zip.ReadByte(); 

    } 
    return bytes.ToArray(); 
    } 
    } 

到现在为止,我不能找到一些方法来压缩我的字节数组,所以我可以用我的.NET方法.. 如果能跟大家对我的问题的任何信息,请告诉我解压缩..

非常感谢.. :)

回答

0

在.Net中,您可以使用System.Convert.FromBase64String将指定的字符串(将二进制数据编码为base-64数字)转换为等效的8位无符号整数数组。

System.Convert.FromBase64String(encodedString); 
+0

嗨Sameer,谢谢你的回答..我需要的只是压缩在钛应用程序中的字节数组,然后通过网络服务传输..你知道如何在钛应用程序压缩字节数组? –

+0

不,但我认为你正在上传图片到服务器这个链接可能会解决你的问题[上传图片到服务器](https://developer.appcelerator.com/question/8471/upload-images-to-a-server) 。 – Sameer

相关问题