Let's follow up this discussion at the Neptune Community
(this forum will be kept in read-only mode)
Hi. I'm using the UI5 FileUploader control to upload files which are then being stored as GOS attachments. During this process, it's quite possible that GOS will throw errors (due to user authorizations or database issues, for example). However, I can't come up so far with any way to communicate these issues to the frontend.
Normally, I either use /NEPTUNE/CL_NAD_SERVER=>API_MESSAGE_CREATE for this purpose or I'll set some oData structures or something like that. However, I noticed in your code in /NEPTUNE/HTTP_HANDLER that you are not allowing any response data to be passed on in the case that a file upload is being executed. This being the case, it seems to me that the only way I can communicate that a problem has occurred would be to trigger a short dump in my code, which is less than ideal, but at least then I'd be able to pick up the 500 status.
Any suggestions on how I should be handling errors in this situation? It's entirely possible that I'm just approaching this from the wrong angle, so any thoughts you have are very welcome. Thanks!
Any chance you will write your own FileUploader?
Hey Patrick, I ended up not doing anything particularly clever to resolve this issue. After saving a newly uploaded file, I just performed a read of the available files and wrote a validation to make sure the file I was trying to add was now in the list of files. Since I was using GOS, I knew that the only likely errors would be due to security role issues, so I just made sure to iron these out as they came up.
Aside from that, my suggestion would be to record an error in an application log so that whenever this happens, you'll have a place to review what went wrong.
You could write your own file upload control, but honestly, you'll likely run into a lot of the same limitations.
thanks for your feedback. Actually i am considering not to use the upload method from FileUploader. Instead using an custom ajax call with a json array of files (base64 encoded) as payload and a json array of file meta data.
What do you think of this workaround?
Hey Patrick, I just saw your question, and I thought I'd respond since I have been working on something similar in the last couple days. I basically implemented what you're describing. I used the SAPUI5 FileUploader control, and in the change event, I just grab the file pointer and append it to a global FormData object. Then, when you want to make your custom AJAX call, you can just do something like this:
var request = new XMLHttpRequest(); request.open("POST","/your_http_handler"); request.send(formData);
This will send the data as a multipart request, which you can parse in your handler using the if_http_request->get_multipart( ) method.