如何将 BitmapData 对象直接上传到我的服务器? [英] How to upload a BitmapData Object straight to my server?

查看:54
本文介绍了如何将 BitmapData 对象直接上传到我的服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望从我的 Flash 应用程序 (AS3) 上传到 imagehacks XML API.我想知道如何做到这一点.

I wish to upload from my Flash Application (AS3) to imageshacks XML API. I wish to know how I can do this.

"在 Flash 中,我们必须使用 UrlRequest 和 UrlLoader 类来 POST 数据,但是我们遇到了 Flash API 的限制.UrlRequest 的数据属性可以是 UrlVariablesByteArray 对象.没有简单的发送方法名称值与 JPG 字节数组一起配对.这是一个大问题,因为大多数上传应用程序都需要文件名和其他标题来伴随原始文件数据"

"In Flash, we must POST the data using the UrlRequest and UrlLoader classes, however we run into a limitation of the Flash API. The data property of a UrlRequest can either be a UrlVariablesByteArray object. There is no easy way to send name value pairs along with the JPG byte array. This is a big problem, because most upload applications will require a filename and other headers to accompany the raw file data"

我希望有人能帮助我克服上述问题!

I was hoping if someone could help me overcome the above!

谢谢大家

我尝试在此处使用本教程:http://www.mikestead.co.uk/2009/01/04/upload-multiple-files-with-a-single-request-in-flash/

I have tried making use of this tutorial here:http://www.mikestead.co.uk/2009/01/04/upload-multiple-files-with-a-single-request-in-flash/

问题在于它不是针对未保存的图像,而是从您的本地计算机获取图像,然后将其上传到图像已经有名称的服务器!

The problem is it's not for unsaved images, but it get images from your local machine and then uploads it to the server where the images has had a name already!

推荐答案

这对我帮助很大:http://kitchen.braitsch.io/upload-bitmapdata-snapshot-to-server-in-as3/

您需要修改 URLRequestWrapper 以在需要的地方插入字段名和文件名.这是我所做的:

You need to modify the URLRequestWrapper to insert field names and file names where needed. Here's what I've done:

bytes = 'Content-Disposition: form-data; name="' + $fieldName + '"; filename="';

它对标题进行了最多的格式化,因此服务器可以将其理解为文件上传.

It does the most formatting of headers so the server could understand it as a file upload.

顺便说一下,如果您有 BitmapData,您可能需要先将其编码为 JPEG 或 PNG.

By the way, if you have a BitmapData you might need to encode it to JPEG or PNG first.

问候,阿尔特姆

这篇关于如何将 BitmapData 对象直接上传到我的服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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