上传从 WriteableBitmap 创建的 JPEG,而不先将其保存到用户计算机
我有一个应用程序,允许用户将视频上传到服务器,该过程的一部分是在客户端上创建缩略图,该缩略图将在服务器上加载时用于视频。我有一个 writeablebitmap,我想将其转换为 jpeg 并上传到服务器。
是否可以在不先将 jpeg 保存到用户计算机的情况下执行此操作 - 我不想需要受信任的应用程序。是否可以先将其存储在独立存储中,然后从那里上传,就好像它只是用户计算机上的另一个文件一样?
谢谢 迈克尔
I have an application that allows users to upload videos to the server and part of the process is to create a thumbnail image on the client that will be used for the video when loaded on the server. I have a writeablebitmap that I want to convert to a jpeg and upload to the server.
Is it possible to do this without saving the jpeg to the user's computer first - I do not want to require a trusted app. Is it possible to store it in isolatedstorage first and then upload it from there as if it is just another file on the user's computer?
thanks
Michael
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须在上传之前保存文件,但当然可以将其保存到隔离存储而不是通用文件系统。
Microsoft 独立存储快速入门可以写入图像。
OpenFile
方法;您可以下载一些代码来帮助您入门。
You will have to save the file before uploading, but it is certainly possible to save it to Isolated Storage rather than the general file system.
There's a Microsoft Quickstart on Isolated Storage that writes an image.
The
OpenFile
method;There's some code you can download which should get you started.
我实现了一个解决方案,允许我获取 WriteableBitmap,使用 FJCore 将其转换为 JPEG,并将其写入 MemoryStream 并将其发送到服务器。
请参阅: 使用 FJCore 编码 Silverlight WriteableBitmap
然后我发现了一个很棒的 FileUploader 类,它我修改为上传 MemoryStream,避免首先创建本地文件。
原始:
修改:
请参阅:http://www.codeproject.com/KB/silverlight/ SL4FileUploadAnd_SL4_MVVM.aspx
在服务器上,我使用上面链接中描述的 FileUpload.ashx 来接受流块并将它们写入服务器上的文件中。
使用 HttpWebRequest 调用 FileUpload.ashx,MemoryStream 会以块的形式向上发送,直到到达流的末尾。
当服务器接收到字节时,它们会被写入指定位置的文件中。
I implemented a solution that allows me to take a WriteableBitmap, convert it to a JPEG using FJCore and write it to a MemoryStream and send it to the server.
see: Using FJCore to encode Silverlight WriteableBitmap
Then I found a great FileUploader class which I modified to upload a MemoryStream avoiding having to create a local file first.
ORIG:
MODIFIED:
see: http://www.codeproject.com/KB/silverlight/SL4FileUploadAnd_SL4_MVVM.aspx
On the server I used the FileUpload.ashx described in the link above to accept the chunks of the stream and write them to a file on the server.
Calling the FileUpload.ashx using a HttpWebRequest, the MemoryStream is sent up in chunks until the end of the stream is reached.
As they bytes are received on the server they are written out to a file in a specified location.