If you are familiar with creating services to provide functionalities to another systems or final users you are maybe aware about the pain in the ass the attachments always are. We are use to work with all the data in memory. We receive a request with their data and we keep it inside the memory working with this data and do the job. That’s the procedure we always work.
But, what we have to do with the attachments? When we work with attachments we are usually working with a lot of data because files always are big. At least they are big if you compare them with the other data inside your request. When you are creating service interfaces a normal practice is to limit the amount of data we can fly inside our online request at a 1 MB maximum or something like this. But, usually we have to deal with this problem and now, the latest version of BusinessWorks 6.x has a native capability to deal with it.
When you are creating an SOAP interface, you can define a Persistence Type option. This feature is a new one and it is very helpful to deal with the problem we are talking about. This setting allows us to specify a threshold size for our attachment and if the attachment goes over that value, it will be persisted to the disk and it is not going to be keeping inside the memory.
When you select this option you can define the following values:
- Directory: The folder where all these files are going to be persisted all long the request is being processed.
- Threshold size: The threshold size of the file. You can specify the amount of data and the magnitude (Bytes, KB or MB).
In my case the configuration is to store inside the folder /tmp/attatchments the files that has more than 100 bytes to do the test. So, if I do a request like the one you can see below where I attach a log file it is going to be persisted into that folder: