Difference in "cfhttpparam type="file"" ACF vs Lucee

In ACF, we used the following to upload a file.

local.httpService.addParam(type="file", name=arguments.displayName, file=arguments.fileLocation);

However in Lucee, it works only if we do this as below.

local.httpService.addParam(type="body", name=arguments.displayName, value=FileReadBinary(arguments.fileLocation));

Is there anything we are missing here or not understanding about the way the http requests work for Lucee. We would like to avoid using FileReadBinary(). Any help is much appreciated.

Don’t forget to tell us about your stack!

OS: Windows Server 2022 Datacenter Azure Edition
Java Version: 11.0.17 (Eclipse Adoptium) 64bit
Tomcat Version: Apache Tomcat/9.0.68
Lucee Version: Lucee 5.4.2.17

can you share a bit more code?

are you using the new Http() style?

Try using the <cfhttp> or tags in script version, http url="dffddf" { httparam name="...}, new http() is only a wrapper around for and was deprecated a long time ago by adobe (so I just learnt recently)

How have you defined local.httpService in ACF and in Lucee?

Will try the http url tag. Yes it’s the old new Http().

/* Deprecated as from Adobe ColdFusion 2018 */
httpService=new http();

but, new Http() is purely just passing thru args to the tags as argumentCollection

httpparam type=file should be working, now either there’s a bug with argumentCollection etc or there is something else in play here.

without seeing the code in question, it’s hard to say

regardless of deprecation status, if there’s a bug and someone wants jump in and fix any of these tags, we are open to PRs, people are still using this and our one of our goals is nice DX (developer experience) for all our users

this includes, new Query(), new Mail() and new Http()

@Gavin_Baumanis encountered a similar problem with new Query() the other day

1 Like

This is the whole section of code which is the PUT request. There’s nothing fancy here. This is not throwing error. However the file is not uploading properly for .docx, or .msg files.

local.httpService = new http(method="PUT", charset="utf-8", url=local.documentViewerServerUrl);
local.httpService.addParam(name="Request-Secret", type="header", value=getDVSecretKey());
local.httpService.addParam(type="file", name=arguments.filename, file=arguments.fileLocation);
local.result = local.httpService.send().getPrefix();
local.httpService.addParam(type="body", name=arguments.displayName, value=FileReadBinary(arguments.fileLocation));

The above code solves it, however we don’t want to do that.

You need to explicitly set the upload to be a file multi part mime type

multipart/form-data via multipart=true

1 Like