如何使用 AS3 / Flash / SWFUpload 处理 HTTPStatus 响应 201
我在 Rails 站点上使用 SWFUpload 来允许将 MP3 直接上传到 Sound Cloud。为了避免必须首先将大文件上传到我的服务器并推送到 Sound Cloud,我直接通过 SWFUpload 使用他们的 API,传递必要的 OAuth 令牌数据。
一切正常 - 除了 - Flash 无法处理 Sound Cloud 的 API 返回的 HTTP 响应代码 (201)。这总是会触发闪存未处理的 IO 错误。尽管 SWFUpload 允许我在 JS 中覆盖它,但它会破坏任何响应数据(上传文件的 URI)。
有谁知道我如何以某种方式拦截 201 代码,以便我可以将其设为 flash 的 200 代码?我不知道如何避免这个 IO 错误。我已经尝试了所有内容的 try/catch 语句,甚至重新编译了 SWFUpload 来尝试新的东西,但没有成功。任何帮助将不胜感激。
I'm using SWFUpload on a Rails site to allow for MP3 Uploads direct to Sound Cloud. To avoid having to first upload a large file to my server and push to Sound Cloud, I'm hitting their API directly via SWFUpload, passing necessary OAuth token data.
Everything works - EXCEPT - Flash can't handle the HTTP response code that Sound Cloud's API returns (201). This ALWAYS triggers an unhandled IO Error with Flash. Even though SWFUpload allows me to override that in the JS, it breaks any response data (the URI to the uploaded file).
Does anyone know how I could somehow intercept the 201 code so that I can make it a 200 code for flash? I'm at a loss at how I can avoid this IO Error. I've tried try/catch statements around everything and have even recompiled SWFUpload to try new things to no avail. Any help would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您唯一能做的就是通过 HTTPStatusEvent 捕获它,然后捕获但忽略 IOError(如果最后一个 HTTPStatusEvent 是 201)。不幸的是,您实际上无法通过这种方式读取响应标头,但您可以知道它已完成。
About the only thing you can do is capture it via an HTTPStatusEvent and then capture but ignore the IOError if the last HTTPStatusEvent was a 201. Unfortunately you can't actually read the response headers this way, but you can tell that it completed.
不幸的是,你完蛋了。 Flex 中无法处理除 200 之外的任何响应代码。任何其他情况都会导致错误。
Unfortunately, you're screwed. It's not possible to handle any response codes other than 200 in Flex. Anything else results in an error.