• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How can we handle posted binary data??

New Here ,
Apr 02, 2006 Apr 02, 2006

Copy link to clipboard

Copied

Hello.

How can we handle posted binary data with CFML??
I'm thinking about handling posted binary data from Flash via URLRequest.
Java servlet can handle this, so I think CFML should be able to do something too.

Can we??

--Shigeru
TOPICS
Advanced techniques

Views

1.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 02, 2006 Apr 02, 2006

Copy link to clipboard

Copied

Have you tried the BinaryEncode() function?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 02, 2006 Apr 02, 2006

Copy link to clipboard

Copied

Shigeru@Linkcom wrote:
> How can we handle posted binary data with CFML??
> I'm thinking about handling posted binary data from Flash via URLRequest.

remoting won't work?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 19, 2006 Apr 19, 2006

Copy link to clipboard

Copied

Hello.

> Have you tried the BinaryEncode() function?
No.
At first I can't post ByteArray Data from Flash to ColdFusion.

> remoting won't work?
No.
I convert Flex2.0 component to BitmapData, then I convert the BitmapData to ByteArray.
And I post ByteArray via RemoteObject to ColdFusion.
But FlashRemoting can't handle sending ByteArray. It seems like handling message eternally (never finish).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 19, 2006 Apr 19, 2006

Copy link to clipboard

Copied

How can we handle posted binary data??
What you want Coldfusion to do with the data? It is not clear to me what you mean by 'handle'.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 19, 2006 Apr 19, 2006

Copy link to clipboard

Copied

Hi.

> What you want Coldfusion to do with the data?
> It is not clear to me what you mean by 'handle'.
Ah, I want to save binary data as a image file.

1. a user paint something at FlashPlayer.
2. a user click "Upload" button.
3. as internal programming, it upload the data to ColdFusion as ByteArray.

Our ( FlexUserGroup at Japan ) samples is here.
http://cvs.sourceforge.jp/cgi-bin/viewcvs.cgi/flex2/PaintExample/

Java servlet ( extends HttpServlet ) can handle this.
So, I thought ColdFusion should handle this, but I have no idea.

How should I??

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 20, 2006 Apr 20, 2006

Copy link to clipboard

Copied

Two ideas


edited: setencoding() added




Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 21, 2006 Apr 21, 2006

Copy link to clipboard

Copied

Hi, thank you for replay and sample code.

I tried "cfscript" way and I got a error like below.
It seems like ColdFusion can't handle binary data.

java.lang.IllegalArgumentException
at javax.servlet.http.HttpUtils.parseQueryString(HttpUtils.java:149)
at javax.servlet.http.HttpUtils.parsePostData(HttpUtils.java:252)
at jrun.servlet.JRunRequest.parsePostData(JRunRequest.java:381)
at jrun.servlet.JRunRequest.getParameters(JRunRequest.java:361)
at jrun.servlet.JRunRequest.getInputStream(JRunRequest.java:239)
at javax.servlet.ServletRequestWrapper.getInputStream(ServletRequestWrapper.java:191)
at coldfusion.filter.FusionContext.getRequestContent(FusionContext.java:602)
at coldfusion.filter.FormScope.fillForm(FormScope.java:202)
at coldfusion.filter.FusionContext.SymTab_initForRequest(FusionContext.java:384)
at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:33)
at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
at coldfusion.filter.RequestThrottleFilter.invoke(RequestThrottleFilter.java:115)
at coldfusion.CfmServlet.service(CfmServlet.java:107)
at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:78)
at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:257)
at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:541)
at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:204)
at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:318)
at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:426)
at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:264)
at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)

04/21 17:09:30 error
java.lang.IllegalArgumentException
at coldfusion.filter.FormScope.parseQueryString(FormScope.java:283)
at coldfusion.filter.FormScope.parsePostData(FormScope.java:255)
at coldfusion.filter.FormScope.fillForm(FormScope.java:206)
at coldfusion.filter.FusionContext.SymTab_initForRequest(FusionContext.java:384)
at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:33)
at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
at coldfusion.filter.RequestThrottleFilter.invoke(RequestThrottleFilter.java:115)
at coldfusion.CfmServlet.service(CfmServlet.java:107)
at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:78)
at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:257)
at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:541)
at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:204)
at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:318)
at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:426)
at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:264)
at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 21, 2006 Apr 21, 2006

Copy link to clipboard

Copied

Post completely revised after I discovered what might be the cause of the above error. Apparently, via the GetHttpRequestData() route, Coldfusion cannot parse the binary data when the encoding is its default UTF-8. Therefore, put this at the top of the page that contains the cfscript code:

<cfset setencoding("form", "UTF-16")>


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 21, 2006 Apr 21, 2006

Copy link to clipboard

Copied

Hi, BKBK.

You were right.
"<cfset setencoding("form", "UTF-16")>" doesn't need.
Actually binary data is posted from ActionScript3 and the reason of taht exception is due to a URLRequest parameter.
"contentType " of URLRequest had to be set in case of ColdFusion (Tomcat doesn't need this).

Thank you for your advice!!

var myReq:URLRequest = new URLRequest(" http://localhost/samples/PaintExample/upload.cfm");
myReq.method = "POST";
myReq.data = data;

// I add this line.
myReq.contentType = "binary";

var myLoader:URLLoader = new URLLoader();
myLoader.addEventListener(flash.events.Event.COMPLETE,completeHandler);
myLoader.addEventListener(flash.events.IOErrorEvent.IO_ERROR,imgUploadIOError);
myLoader.addEventListener(flash.events.SecurityErrorEvent.SECURITY_ERROR,imgUploadSecurityError);
myLoader.load(myReq);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 21, 2006 Apr 21, 2006

Copy link to clipboard

Copied

"<cfset setencoding("form", "UTF-16")>" doesn't need.
Actually binary data is posted from ActionScript3 and the reason of taht exception is due to a URLRequest parameter.
"contentType " of URLRequest had to be set in case of ColdFusion (Tomcat doesn't need this).


I was also disappointed to discover that Coldfusion includes header data like

-----------------------------7d6108d1304e4
Content-Disposition: form-data; name="FileContents"; filename="C:\Documents and Settings\Administrator\My Documents\My Pictures\MS_Sample.jpg"
Content-Type: image/pjpeg


before the actual GetHttpRequestData().content data, and

-----------------------------7d6108d1304e4
Content-Disposition: form-data; name="submit"
Upload File
-----------------------------7d6108d1304e4--


after it. Might be difficult to handle dynamically. I wonder if there is a neat way to remove that.

Thank you, too, for the useful Actionscript code.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 22, 2006 Apr 22, 2006

Copy link to clipboard

Copied

Hi, BKBK.

I'm curious to know how you dump like "... ----7d6108d1304e4 ...".
It's very useful information when network problem happens.

Could you tell us the dumping way ??

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 22, 2006 Apr 22, 2006

Copy link to clipboard

Copied

Hi Shigeru,

The following code might work for you. However, when the content comes from an upload-form, Coldfusion includes header-information with the binary data, as I described in my previous post.

Version 2 requires an explanation. Christian Cantrell's article gives one.



Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 23, 2006 Apr 23, 2006

Copy link to clipboard

Copied

Hi, BKBK.

Thank you so much!!
Actually I don't try the code yet.
But I'll try to figure out those code and I'll explain it at my blog in Japanese.

Thanks.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 24, 2006 Apr 24, 2006

Copy link to clipboard

Copied

LATEST
どういたしまして。

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation