This block of code is repeated with only difference 1 string, so it should made into a local function:

```
                                    file.write(data, function (err) {
                                        if (err) {
                                            errorCallback(err);
                                        } else {
                                            successCallback(file);
                                        }
                                    });

```