0

I have an enterprise service bus with a collection of services. There is an HTML5 user interface that allows customers to perform all sorts of selfcare actions. The UI uses JavaScripts that communicate with the ESB in JSON format through an API server.

Now I want to offer the customer the possibility to upload documents. I can base64 the document and send it as a JSON field, but that doesn't seem right. What is a good pattern I could use?

  • Sending binary data via REST will require a Base-64 encoded document I don't see a problem with this approach. SOAP services allows you to send the file as a binary attachments though. See this link for more information: http://stackoverflow.com/questions/1156429/how-do-i-write-a-restful-web-service-that-accepts-a-binary-file-pdf – Namphibian Oct 07 '14 at 00:11
  • @Namphibian I see a big problem with this approach. Usually SOA architectures use queue and usually those have limits on the size of the message. Sending the file as part of a service call is definitely not the right approach. – MeTitus Oct 13 '14 at 15:16
  • @Marco being right or wrong would be stipulated by the requirements of the project. Sending files via SOAP is counter intuitive I agree but it can be done and the method is technically sound. Whether it is a good idea can be debated. – Namphibian Oct 13 '14 at 19:58
  • @Namphibian I am sure it can done, but if asked to give an opinion about that, I would say that the approach is wrong. – MeTitus Oct 14 '14 at 08:55
  • @Marco I fully agree with you. I missed the part of the question where the OP asked if there was a better design pattern. So I upvoted your answer as it makes a hell of lot more sense. I was focussed on the technical details. – Namphibian Oct 14 '14 at 09:06

1 Answers1

1

It does not sound right because it is not right.

In this cases you should a write the file to a write only public FTP given it a GUID name and then send a message to the service giving details about the files. On the service side once a message with the file details is received, store the metadata in your persistence layer and copy the files to a private FTP.

Something like this:

Claim Check Pattern

MeTitus
  • 3,390
  • 2
  • 25
  • 49