Forum Discussion
VarunGrazitti Thanks! I'm running into an interesting issue:
Here's the content of my test endpoint:
<#assign status = "error" />
<#assign message = "no errors" />
<#assign upload_payload = http.request.parameters.name.get("image.content", "") />
<#compress>
<#attempt>
<#assign response = rest("/users/id/${user.id}/media/albums/default/public/images/upload?image.content=${upload_payload}") />
<#assign status = "success" />
<#recover>
<#assign message = .error />
</#attempt>
</#compress>
and this is the test form that is submitting to the EP:
<form method="post" action="/my-path/upload-test" enctype="multipart/form-data">
<input type="file" name="image.content"><br />
<input type="submit" value="Upload" /><br />
</form>
So super simple. What I'm seeing is that the line:
<#assign upload_payload = http.request.parameters.name.get("image.content", "") />
is setting the variable "upload_payload" to an empty string, probably because we failed to find a request param called "image.content". Is there another way I should be getting at the image.content variable that's being uploaded by the form?
Thanks for your help!
Cheers,
Tripp
So I've done a little more testing on this and noticed something:
I added a new field to the form:
<input type="text" name="image.title" value="The light is green" />
and I commented out the "file" input field.
Submitting the new form to the endpoint I found that the new field is also not found. So I removed the form's enctype attribute and resubmitted the form and the image.title parameter is now found and shows the correct data. So it appears that the multipart/form-data enctype is confusing the endpoint (or at least http.request.parameters). Any thoughts on this?
Cheers,
Tripp
Related Content
- 2 years ago
- 13 years ago