二进制文件转换为Base64编码字符串 [英] Converting binary file to Base64 string

查看:693
本文介绍了二进制文件转换为Base64编码字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要上传的二进制文件转换为Base64字符串格式的飞行。我使用ASP,VBScript中。利用绿的成分为base64相互转换。对于小尺寸文件(小于20K)的表现是好的。但是,当它超过75或100K,其完全丧失。是否有大的二进制文件(2MB)转换为base64字符串格式的任何有效的方式?

I need to convert uploaded binary files to base64 string format on the fly. I'm using ASP, Vbscript. Using Midori's component for base64 conversion. For small size files (<20K) the performance is okay. But when it exceeds 75 or 100K, its totally lost. Is there any efficient way to convert big binary files (2MB) to base64 string format?

在此先感谢,
肯尼

Thanks in advance, Kenney

推荐答案

我已经实现.NET组件转换为base64字符串解决了这个问题。困难的部分是从ASP发送到.NET COM二进制数据被接收为字符串。 Convert.ToBase64()只接受的byte []。所以我试图将字符串转换为byte []。

I have solved this issue by implementing a .net component for converting to base64 string. The hard part is the binary data sent to the .net COM from ASP is received as a string. Convert.ToBase64() accepts only byte[]. So I tried converting string to byte[].

但在.NET中可用的编码(统一code,ASCII,UTF)不正常工作。有数据丢失,而使用这些编码。最后,我得到它通过使用StringReader对象来完成。成炭(16位)读取字符,并将其转换为(8位)byte []数组。

But the encoding available in .net (Unicode, ASCII, UTF) doesn't works fine. There are data loss, while these encodings are used. Finally I get it done by using StringReader object. Read char by char(16 bit) and converted them to (8 bit) byte[] array.

和性能是最好的。

问候,
湿婆。

Regards, Siva.

这篇关于二进制文件转换为Base64编码字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆