Hello ALL,
I am trying to implement a restful service to upload product's image.
Ofbiz calls a groovy file EditProductContent.groovy for uploading through web browser.
Reference taken from:
https://cwiki.apache.org/confluence/display/OFBIZ/Export+service+using+RESTFor testing purpose I have hard coded the productId for now and tried calling the same groovy file.
@POST
@Path("/uploadProductImage")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public String uploadProductImage(BufferedInMultiPart bimp, @Context HttpServletRequest request) {
try {
GenericDelegator delegator = (GenericDelegator) DelegatorFactory.getDelegator("default");
GenericEntity product = delegator.findOne("Product", UtilMisc.toMap("productId", "10000"), false);
Map<String, Object> context = FastMap.newInstance();
//required parameters for groovy
context.put("productId", product.productId);
context.put("product", product);
context.put("delegator", delegator);
context.put("request", request);
GroovyUtil.runScriptAtLocation("component://product/webapp/catalog/WEB-INF/actions/product/EditProductContent.groovy", null, context);
} catch (GeneralException e) {
e.printStackTrace();
}
return "";
This code further ends up in HttpRequestFileUpload.java, doUpload method after failing to read the data and throws IOException
HTTP Status 500 - java.io.IOException: waited 21 times, bailing out while still expecting 561465 bytes.
Any guidance would be really helpful.
Thanks