# Class Storage#fsync

storage

- Defined in: storage.js

Class Summary
Constructor Attributes | Constructor Name and Description
--- | ---
| Storage#fsync(successCallback, errorCallback, options) Flushes modified files to filesystem.

## Class Detail

Storage#fsync(successCallback, errorCallback, options)
Flushes modified files to filesystem.

    function fsync() {
       // This example will copy a file to USB and sync it.

       var failureCb = function(cbObject){
         var errorCode = cbObject.errorCode;
         var errorText = cbObject.errorText;
         console.log( " Error Code [" + errorCode + "]: " + errorText);
       };

       var storage = new Storage();
       storage.copyFile(
         function(){  // Copy was success. fsync the file.
            storage.fsync(
               function(){
                  console.log("File synched!!!!!!!!!!");
               },
               failureCb,
               {path : "file://usb:1/file.jpg"}
            );
         },
         failureCb,
         {source:"file://internal/this.jpg", destination:"file://usb:1/file.jpg"}
       );

       // This example will sync whole file system.
       var failureCb = function(cbObject){
         var errorCode = cbObject.errorCode;
         var errorText = cbObject.errorText;
         console.log( " Error Code [" + errorCode + "]: " + errorText);
      };

       storage.copyFile(
         function(){  // Copy was success. fsync the device.
            storage.fsync(
               function(){
                  console.log("File synched!!!!!!!!!!");
               },
               failureCb, // Failure Callback
               {} // Options
            );
         },
         failureCb, 	// Failure Callback
         {source:"file://internal/this.jpg", destination:"file://usb:1/file.jpg"} // Options
       );

    }

Parameters:
{Function} successCallback
  success callback function.
{Function} errorCallback
  failure callback function.
{Object} options

  Property | Type | Description | Required
  --- | --- | --- | ---
  path | Storage.SCAP_URI | URI to the resource (internal/usb/sdcard).If this parameter is not provided, whole file system is synced using 'sync' linux command. | optional

Since:
  1.2
Returns:

  After the method is successfully executed, successCallback is called without any parameter. If an error, errorCallback is called with errorCode and errorText. To see how error codes are defined, check Error.ERROR_CODE