Example #1
0
    def setcontents(self, path, data, chunk_size=1024 * 64):
        """A convenience method to create a new file from a string or file-like object

        :param path: a path of the file to create
        :param data: a string or a file-like object containing the contents for the new file
        :param chunk_size: Number of bytes to read in a chunk, if the implementation has to resort to a read / copy loop
        
        """

        if not data:
            self.createfile(path)
        else:
            compatibility.copy_file_to_fs(data, self, path, chunk_size=chunk_size)
Example #2
0
 def do_setcontents():
     try:
         compatibility.copy_file_to_fs(
             data,
             self,
             path,
             chunk_size=chunk_size,
             progress_callback=progress_callback,
             finished_callback=finished_callback,
         )
     except Exception, e:
         if error_callback is not None:
             error_callback(e)