I have written the following function in the helper library:

exports.createXML = function(ExportFile, XMLObj){

    var writer = new FileWriter(ExportFile, 'UTF-8');

    var xsw = new XMLStreamWriter(filewriter);





[Here, ExportFile is an object of the class dw.io.File and XMLObj is an object of the class XML]

And I have written another code using class FileWriter, but I always encounter the error saying Limit for quota 'api.dw.io.FileWriter(File)' exceeded. Limit is 0, actual is 1. We are currently using the SFRA architecture.

I have gone through many mail threads and XChange questions and discussions on this topic, nothing seems to solve this issue.

I am trying to convert an old custom Workflow to new custom Job component.

What should I do to solve this issue?

Thanks in advance.


You cannot access a file for writing in a Storefront context.

I'd likely ask you first, "Is what you're doing absolutely necessary in a storefront context?" Then secondly, "Can you break your functionality into a two-step process whereby the file writing occurs as an asynchronous job that polls for new work every few minutes?"

The answer to the first question in this case I'd assume is: "I'm trying to test this functionality using a storefront controller because testing jobs can be problematic." If that were true, I'd tell you to deal with it because this quota is going to prevent you from getting your task done. Just do it as a standalone job w/ component and feed it what it needs. Maybe you put a file on the WebDAV and ensure it's there before running your job component.

If the answer is not what I've assumed above: You'll need to find a way to either store that payload as a Custom Object for later writing in a Job context or use a third party to store it either temporarily or permanently.

See quota documentation: https://documentation.b2c.commercecloud.salesforce.com/DOC2/topic/com.demandware.dochelp/DWAPI/quota/html/API_Quotas.html

The reason for this quota is to prevent storefront threads being locked by system-level IO operations. It would be really easy to DDoS a site that had file uploads going right onto disk.

Note that you can upload files via HTTP Multipart MIME POST and they can be stored and you can operate on them. This mechanism should not be used to accept Import/Export XML as that is not secure.

  • I have written this function as a helper function, but initially, I am just feeding the values to it, then I am getting quota error. But when I used this code with my, my job worked perfectly, I didnt understand the situation here. I mean why can I just feed the values to this function and then test it, rather it just works perfectly with the job? Can you please help me understand the situation here? – Code_Ninja May 21 at 7:09
  • I already explained in my answer why it doesn’t work in a storefront context. That is because within a storefront request there is a quota to prevent you from writing to a file in that type of context. The reason it is there is to protect against performance issues for you and other merchants on the same POD. – sholsinger May 23 at 12:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.