Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
7 replies
Subscribers
6 subscribers
Views
2624 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
Process
Could somebody confirm that the smart service HTTP File Upload uses by default a
orlandom
over 9 years ago
Could somebody confirm that the smart service HTTP File Upload uses by default as the content type of POST requests "multipart/form-data"?
If that is so, how could I change the content-type to "application/x-www-form-urlencoded"? Passing it as a part of a header parameter seems to be ignored.
In fact, all I want to do is the equivalent of the following Java code (that is, the only thing written into the body of the request are the bytes of the file):
File fileToUpload = new File("test.doc");
String url = "localhost:8080/les-services/HttpContentHandler.ashx?token=" +
authenticationToken + "&contextID=" + contextID + "&fileName=test.doc" +
"&fileSize=" + fileToUpload.length();
URL obj = new URL(url);
con = (HttpURLConnection) obj.openConnection();
con.setDoOutput(true);
con.setRequestProperty("User-Agent", "Mozilla/5.0");
con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
PrintWriter wr = new...
OriginalPostID-151025
OriginalPostID-151025
Discussion posts and replies are publicly visible
0
orlandom
over 9 years ago
... PrintWriter(new OutputStreamWriter(con.getOutputStream(), "UTF-8"));
Files.copy(fileToUpload.toPath(), con.getOutputStream());
con.getOutputStream().flush();
wr.append(CRLF).flush();
wr.close();
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Stefan Helzle
A Score Level 3
over 9 years ago
AFAIK you cannot upload a file URL encoded. This would mean to put the file content into the URL which.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Stefan Helzle
A Score Level 3
over 9 years ago
is not allowed to be long enough by the specification.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
orlandom
over 9 years ago
Right. Could I then pass an empty value using the smart service? My problem seems to be linked to the content type being "multipart/form-data" by default.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Stefan Helzle
A Score Level 3
over 9 years ago
So your problem is that the server you try to send the file to does not accept this content-type?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
orlandom
over 9 years ago
I am still not clear on what my problem is. What I think is that the server handler takes everything written on the request body as the contents of the file so I end up with header information on the uploaded file and thus it is corrupted. Since the handler takes all the required parameters from the URI, I do not need to write anything on the request body besides the file bytes. But the smart service does not give me this flexibility, it appears, which of course I have with pure Java code.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Stefan Helzle
A Score Level 3
over 9 years ago
Check
www.huyng.com/.../
for how a correct request has to look. Appian does it the right way. Any chance you can modify the server side. If not you need to write an Appian plugin.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel