2014-02-18 62 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

相關問題