MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / storeFile

Method storeFile

pager_lib/smb/SMBProtocol.py:284–304  ·  view source on GitHub ↗

Store the contents of the *file_obj* at *path* on the *service_name*. The meaning of the *timeout* parameter will be different from other file operation methods. As the uploaded file usually exceeeds the maximum size of each SMB/CIFS data message, it will be packetized into

(self, service_name, path, file_obj, timeout = 30)

Source from the content-addressed store, hash-verified

282 return d
283
284 def storeFile(self, service_name, path, file_obj, timeout = 30):
285 """
286 Store the contents of the *file_obj* at *path* on the *service_name*.
287
288 The meaning of the *timeout* parameter will be different from other file operation methods. As the uploaded file usually exceeeds the maximum size
289 of each SMB/CIFS data message, it will be packetized into a series of messages (usually about 60kBytes).
290 The *timeout* parameter is an integer/float value that specifies the timeout interval for these individual SMB/CIFS message to be transmitted and acknowledged
291 by the remote SMB/CIFS server.
292
293 :param string/unicode service_name: the name of the shared folder for the *path*
294 :param string/unicode path: Path of the file on the remote server. If the file at *path* does not exist, it will be created. Otherwise, it will be overwritten.
295 If the *path* refers to a folder or the file cannot be opened for writing, an :doc:`OperationFailure<smb_exceptions>` will be called in the returned *Deferred* errback.
296 :param file_obj: A file-like object that has a *read* method. Data will read continuously from *file_obj* until EOF. In Python3, this file-like object must have a *read* method which returns a bytes parameter.
297 :return: A *twisted.internet.defer.Deferred* instance. The callback function will be called with a 2-element tuple of ( *file_obj*, number of bytes uploaded ).
298 """
299 if not self.instance:
300 raise NotConnectedError('Not connected to server')
301
302 d = defer.Deferred()
303 self.instance._storeFile(service_name, path, file_obj, d.callback, d.errback, timeout = timeout)
304 return d
305
306 def deleteFiles(self, service_name, path_file_pattern, delete_matching_folders = False, timeout = 30):
307 """

Callers

nothing calls this directly

Calls 1

NotConnectedErrorClass · 0.70

Tested by

no test coverage detected