【问题标题】:How to compress Ti.utils.base64encode and decompress using .Net method?如何使用 .Net 方法压缩 Ti.utils.base64encode 和解压缩?
【发布时间】:2014-02-18 13:00:30
【问题描述】:

有人知道如何压缩 Ti.Utils.base64encode 吗? 例如我有这个代码:

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

这是我的网络服务中从钛解压缩图像的方法(如果我之前可以压缩我的图像):

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 方法解压缩它们。 如果你们有任何关于我的问题的信息,请告诉我..

非常感谢.. :)

【问题讨论】:

    标签: android asp.net compression titanium base64


    【解决方案1】:

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

    System.Convert.FromBase64String(encodedString);
    

    【讨论】:

    • 嗨 Sameer,感谢您的回答.. 我只需要在钛应用程序中压缩我的字节数组,然后通过 Web 服务传输它.. 你知道如何在钛应用程序中压缩字节数组吗?
    • 不,但我认为您正在将图像上传到服务器,此链接可能会解决您的问题Upload images to a server
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-22
    • 1970-01-01
    • 2019-01-29
    • 1970-01-01
    相关资源
    最近更新 更多