InoDrive / File / write
InoDrive.File.write(self, files=None, transfer_type=None)
Write file(s) operation to InoDrive with provided file path and content object.
Arguments:
• self (Object): Reference to InoDrive File Instance.
• files (Dict or List): A single File or a group of Files to iterate through. Each entry needs a File Path and its content in Raw Binary.
• transfer_type (Number): TLV command header, for non UserApp/Firmware files it can remain blank or None.
Returns: Boolean – True or False on successfully writing file(s) out.
import CkInoDriveAPI import os # Instantiate InoDrive Object and Connect by Name Drive = CkInoDriveAPI.InoDrive(target='Name', autoConnect=True) # Get Relative Path to File filePath = os.path.relpath("File Path") # Open File in Raw Binary Format fs = open(filePath, "rb") # If File Stream exists read File Contents and close it if fs: file_content = fs.read() fs.close() # Write File Out if file_content is not None: result = Drive.File.write({'path': '/dir/file1.json', 'content': file_content})