尝试分块上传文件(图像),合并上传的字节后文件损坏,为什么?
尝试在 silverlight 应用程序中创建自定义上传控件来上传大文件。我有非常小的图像用于测试 753 字节大小。当我设置块大小 = 753 时,一切正常,控件一次接收所有 753 个字节,然后我将这些字节数组写入 FileSaveAs 对话框(用于测试目的)流,上传的字节显示为上传图像的副本。当我设置块大小= 500时,那么我们需要2个块500 + 253,在调试时我比较这些字节(两个块),并且两者与上传一个块时的情况相同..唯一的区别 - 我有 2 个数组而不是 1 个。将这些合并的块保存到新图像文件后,此文件已损坏。它的大小与原始大小完全相同,但它已损坏,我无法预览它。无法弄清楚那里有什么问题,有什么想法吗?
我附上了这些图片:那里
a.jpg - 原始 b.jpg - 损坏(以 500 + 253 块上传) c.jpg - 当块大小 = 753 时上传
Trying to create custom upload control in silverlight app for uploading large file. I've very small image for testing 753 bytes size. When i set chunk size = 753 everything works fine, control recieves all 753 bytes at once, then i write these bytes array to FileSaveAs dialog (for testing purposes) stream and uploaded bytes appears as copy of uploaded image. When i set chunk size lets say = 500, then we need 2 chunks 500 + 253, when debuging i compare these bytes (two chunks) and both are the same as in case when uploading in one chunk.. the only one difference - i have 2 arrays instead of 1. After saving these merged chunks to new image file this file is corrupted. Its exactly the same size as original, but its corrupted i'm unable to preview it. Can't figure out whats the problem there, any ideas?
I've atached these images: there
a.jpg - original
b.jpg - corupted (uploaded in chunks 500 + 253)
c.jpg - uploaded when chunk size = 753
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来你的 2 块场景中的第一个块不知何故完全搞砸了。
为了帮助您解决问题,我们需要查看相关来源。
Looks like the first chunk in your 2-chunk-scenario got somehow totally messed up.
To help you with the problem, we need to see the relevant source.