My domain layer requires an entity to have 1:N images associated with it.
As FineUploader sends each image as a separate request, i am creating an entity (server side) on the first request and sending the ID of that back in the first response JSON to be added to the subsequent requests, so that the remaining images have an entity relationship ID to be saved with. This is all working well, except the new ID returned from the first request is not being appended to the next request.
I am using setParams to append the ID by hooking onto the onComplete event, as follows:
var uploader = new qq.FineUploader({
debug: true,
element: document.getElementById('fine-uploader'),
allowedExtensions: ['jpg', 'jpeg', 'bmp', 'png','gif'],
callbacks : {
onComplete : function(id, name, responseJSON){
this.setParams({entityId: responseJSON.entityId});
}
}
});
The new param is not added to request URI or post data. What am i doing wrong?
(Using FineUploader 5.15.3, debugged on FireFox Developer Edition, PHP 7.1 server side)
Just a wild guess (I do not have the environment to try it myself):
var entityId = '';
var uploader = new qq.FineUploader({
debug: true,
// *** This is the part I added
request: {
params: { entityId: entityId }
},
element: document.getElementById('fine-uploader'),
allowedExtensions: ['jpg', 'jpeg', 'bmp', 'png','gif'],
callbacks : {
onComplete : function(id, name, responseJSON){
//**** This is the part I changed
entityId = responseJSON.entityId;
// this.setParams({entityId: responseJSON.entityId});
}
}
});
Basically what I intend to do is to get the entityId from the response and feed it as a parameter to the next request.
I hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With