GetHttpRequestData() content not binary

172 views
Skip to first unread message

Jonathan Brookins

unread,
Mar 17, 2017, 11:52:31 AM3/17/17
to Lucee
I'm running into the same problem addressed in https://luceeserver.atlassian.net/browse/LDEV-1009.  The content of the GetHttpRequestData() isn't binary, which I need to use to create the resulting image file. Has this been fixed, or is there a workaround?

Julian Halliwell

unread,
Mar 17, 2017, 12:12:16 PM3/17/17
to lu...@googlegroups.com
Could you use CharsetDecode() as a workaround to convert the string to binary?

http://docs.lucee.org/reference/functions/charsetdecode.html

Jonathan Brookins

unread,
Mar 17, 2017, 1:37:11 PM3/17/17
to Lucee
I tried BinaryDecode() without success, but I'll give your idea a try.

Jonathan Brookins

unread,
Mar 17, 2017, 2:52:29 PM3/17/17
to Lucee
I'm unsure what encoding GetHttpRequestData().content is using. I tried utf-8, utf-16, and a few others without success using CharsetDecode().  I may end up just having to get the underlying input stream and trying to work with that.

Jonathan Brookins

unread,
Mar 17, 2017, 4:40:37 PM3/17/17
to Lucee
Ok, I think that the GetHttpRequestData().content is actually binary, or at least isBinary() returned true for it.  My problem is that I'm trying to implement FineUploader(https://fineuploader.com/), restricting it to image files, and save the uploaded image file.  The FineUploader project does have some coldfusion code to use, but it wasn't working for me.  Bottom line is if the content is the image binary shouldn't I be able to do something like this:

uploadedImage = ImageNew(GetHttpRequestData().content);
ImageWrite(uploadedImage, filePath, 0.8, true);

When I do that it crashes on ImageNew() with a RenderOps exception.

Julian Halliwell

unread,
Mar 18, 2017, 5:22:07 AM3/18/17
to lu...@googlegroups.com
I've had a play with FineUploader and simply handling the request with FileUpload() seems to work:

//uploader.cfc
component{

variables.uploadFolderPath = ExpandPath( "uploads/" ); //set your destination here

remote struct function process() returnFormat="json" {
var uploadResult = FileUpload( uploadFolderPath, "qqfile", "image/jpeg,image/x-png", "makeunique" );
header name="content-type" value="text/plain";
return { success: true };
}

}

Just set your fineuploader endpoint to 'uploader.cfc?method=process'

The uploadResult variable will be a struct allowing you to work with the uploaded file.

Julian.
Reply all
Reply to author
Forward
0 new messages