513
513
return self.put_file(relpath, f, mode=mode)
515
def put_bytes(self, relpath, bytes, mode=None):
516
"""Atomically put the supplied bytes into the given location.
518
:param relpath: The location to put the contents, relative to the
520
:param bytes: A bytestring of data.
521
:param mode: Create the file with the given mode.
524
assert isinstance(bytes, str), \
525
'bytes must be a plain string, not %s' % type(bytes)
526
return self.put_file(relpath, StringIO(bytes), mode=mode)
528
def put_bytes_non_atomic(self, relpath, bytes, mode=None,
529
create_parent_dir=False):
530
"""Copy the string into the target location.
532
This function is not strictly safe to use. See
533
Transport.put_bytes_non_atomic for more information.
535
:param relpath: The remote location to put the contents.
536
:param bytes: A string object containing the raw bytes to write into
538
:param mode: Possible access permissions for new file.
539
None means do not set remote permissions.
540
:param create_parent_dir: If we cannot create the target file because
541
the parent directory does not exist, go ahead and
542
create it, and then try again.
544
assert isinstance(bytes, str), \
545
'bytes must be a plain string, not %s' % type(bytes)
546
self.put_file_non_atomic(relpath, StringIO(bytes), mode=mode,
547
create_parent_dir=create_parent_dir)
515
549
def put_file(self, relpath, f, mode=None):
516
550
"""Copy the file-like object into the location.
530
564
return self.put(relpath, f, mode=mode)
531
565
#raise NotImplementedError(self.put_file)
533
def put_bytes(self, relpath, bytes, mode=None):
534
"""Atomically put the supplied bytes into the given location.
536
:param relpath: The location to put the contents, relative to the
538
:param bytes: A bytestring of data.
539
:param mode: Create the file with the given mode.
542
assert isinstance(bytes, str), \
543
'bytes must be a plain string, not %s' % type(bytes)
544
return self.put_file(relpath, StringIO(bytes), mode=mode)
546
def non_atomic_put_file(self, relpath, f, mode=None,
567
def put_file_non_atomic(self, relpath, f, mode=None,
547
568
create_parent_dir=False):
548
569
"""Copy the file-like object into the target location.
571
592
self.mkdir(parent_dir)
572
593
return self.put_file(relpath, f, mode=mode)
574
def non_atomic_put_bytes(self, relpath, bytes, mode=None,
575
create_parent_dir=False):
576
"""Copy the string into the target location.
578
This function is not strictly safe to use. See
579
Transport.non_atomic_put_bytes for more information.
581
:param relpath: The remote location to put the contents.
582
:param bytes: A string object containing the raw bytes to write into
584
:param mode: Possible access permissions for new file.
585
None means do not set remote permissions.
586
:param create_parent_dir: If we cannot create the target file because
587
the parent directory does not exist, go ahead and
588
create it, and then try again.
590
assert isinstance(bytes, str), \
591
'bytes must be a plain string, not %s' % type(bytes)
592
self.non_atomic_put_file(relpath, StringIO(bytes), mode=mode,
593
create_parent_dir=create_parent_dir)
595
595
@deprecated_method(zero_eleven)
596
596
def put_multi(self, files, mode=None, pb=None):
597
597
"""Put a set of files into the location.