owncloud/owncloud.py
def __put_file_chunked(self, remote_path, local_source_file, **kwargs):
        """Uploads a file using chunks. If the file is smaller than
        ``chunk_size`` it will be uploaded directly.

        :param remote_path: path to the target file. A target directory can
        also be specified instead by appending a "/"
        :param local_source_file: path to the local file to upload
        :param \*\*kwargs: optional arguments that ``put_file`` accepts
        :returns: True if the operation succeeded, False otherwise
        :raises: ResponseError in case an HTTP error status was returned
        """
        chunk_size = kwargs.get('chunk_size', 10 * 1024 * 1024)
        result = True
        transfer_id = int(time.time())

        remote_path = self.__normalize_path(remote_path)
        if remote_path[-1] == '/':
            remote_path += os.path.basename(local_source_file)

        stat_result = os.stat(local_source_file)

        file_handle = open(local_source_file, 'r', 8192)
        file_handle.seek(0, os.SEEK_END)
        size = file_handle.tell()
        file_handle.seek(0)

        headers = {}
        if kwargs.get('keep_mtime', True):
            headers['X-OC-MTIME'] = stat_result.st_mtime

        if size == 0:
            return self.__make_dav_request(
                    'PUT',
                    remote_path,
                    data = '',
                    headers = headers
                    )

        chunk_count = size / chunk_size

        if chunk_count > 1:
            headers['OC-CHUNKED'] = 1

        if size % chunk_size > 0:
            chunk_count += 1
       
        for chunk_index in range(0, chunk_count):
            data = file_handle.read(chunk_size)
            if chunk_count > 1:
                chunk_name = '%s-chunking-%s-%i-%i' % \
                        (remote_path, transfer_id, chunk_count, chunk_index)
            else:
                chunk_name = remote_path

            if not self.__make_dav_request(
                    'PUT',
                    chunk_name,
                    data = data,
                    headers = headers
                ):
                result = False
                break

        file_handle.close()
        return result
Uploads a file using chunks. If the file is smaller than
        ``chunk_size`` it will be uploaded directly.

        :param remote_path: path to the target file. A target directory can
        also be specified instead by appending a "/"
        :param local_source_file: path to the local file to upload
        :param \*\*kwargs: optional arguments that ``put_file`` accepts
        :returns: True if the operation succeeded, False otherwise
        :raises: ResponseError in case an HTTP error status was returned
        
Uploads a file using chunks. If the file is smaller than
``chunk_size`` it will be uploaded directly.
Uploads a file using chunks . If the file is smaller than ` ` chunk_size ` ` it will be uploaded directly .
def __put_file_chunked(self, remote_path, local_source_file, **kwargs):
        chunk_size = kwargs.get('chunk_size', 10 * 1024 * 1024)
        result = True
        transfer_id = int(time.time())
        remote_path = self.__normalize_path(remote_path)
        if remote_path[-1] == '/':
            remote_path += os.path.basename(local_source_file)
        stat_result = os.stat(local_source_file)
        file_handle = open(local_source_file, 'r', 8192)
        file_handle.seek(0, os.SEEK_END)
        size = file_handle.tell()
        file_handle.seek(0)
        headers = {}
        if kwargs.get('keep_mtime', True):
            headers['X-OC-MTIME'] = stat_result.st_mtime
        if size == 0:
            return self.__make_dav_request(
                    'PUT',
                    remote_path,
                    data = '',
                    headers = headers
                    )
        chunk_count = size / chunk_size
        if chunk_count > 1:
            headers['OC-CHUNKED'] = 1
        if size % chunk_size > 0:
            chunk_count += 1
        for chunk_index in range(0, chunk_count):
            data = file_handle.read(chunk_size)
            if chunk_count > 1:
                chunk_name = '%s-chunking-%s-%i-%i' % \
                        (remote_path, transfer_id, chunk_count, chunk_index)
            else:
                chunk_name = remote_path
            if not self.__make_dav_request(
                    'PUT',
                    chunk_name,
                    data = data,
                    headers = headers
                ):
                result = False
                break
        file_handle.close()
        return result
def __put_file_chunked ( self , remote_path , local_source_file , ** kwargs ) : chunk_size = kwargs . get ( 'chunk_size' , 10 * 1024 * 1024 ) result = True transfer_id = int ( time . time ( ) ) remote_path = self . __normalize_path ( remote_path ) if remote_path [ - 1 ] == '/' : remote_path += os . path . basename ( local_source_file ) stat_result = os . stat ( local_source_file ) file_handle = open ( local_source_file , 'r' , 8192 ) file_handle . seek ( 0 , os . SEEK_END ) size = file_handle . tell ( ) file_handle . seek ( 0 ) headers = { } if kwargs . get ( 'keep_mtime' , True ) : headers [ 'X-OC-MTIME' ] = stat_result . st_mtime if size == 0 : return self . __make_dav_request ( 'PUT' , remote_path , data = '' , headers = headers ) chunk_count = size / chunk_size if chunk_count > 1 : headers [ 'OC-CHUNKED' ] = 1 if size % chunk_size > 0 : chunk_count += 1 for chunk_index in range ( 0 , chunk_count ) : data = file_handle . read ( chunk_size ) if chunk_count > 1 : chunk_name = '%s-chunking-%s-%i-%i' % ( remote_path , transfer_id , chunk_count , chunk_index ) else : chunk_name = remote_path if not self . __make_dav_request ( 'PUT' , chunk_name , data = data , headers = headers ) : result = False break file_handle . close ( ) return result
Uploads a file using chunks.
Uploads a file using chunks .
"""Uploads a file using chunks. If the file is smaller than
        ``chunk_size`` it will be uploaded directly.

        :param remote_path: path to the target file. A target directory can
        also be specified instead by appending a "/"
        :param local_source_file: path to the local file to upload
        :param \*\*kwargs: optional arguments that ``put_file`` accepts
        :returns: True if the operation succeeded, False otherwise
        :raises: ResponseError in case an HTTP error status was returned
        """
True if the operation succeeded, False otherwise
True if the operation succeeded False otherwise
ResponseError in case an HTTP error status was returned
ResponseError in case an HTTP error status was returned
self
remote_path
path to the target file. A target directory can
also be specified instead by appending a "/"
path to the target file . A target directory can also be specified instead by appending a " / "
local_source_file
path to the local file to upload
path to the local file to upload
\*\*kwargs
optional arguments that ``put_file`` accepts
optional arguments that ` ` put_file ` ` accepts