501
501
@deprecated_method(zero_eleven)
502
502
def put(self, relpath, f, mode=None):
503
"""Copy the file-like or string object into the location.
503
"""Copy the file-like object into the location.
505
505
:param relpath: Location to put the contents, relative to base.
506
:param f: File-like or string object.
506
:param f: File-like object.
507
507
:param mode: The mode for the newly created file,
508
508
None means just use the default
543
543
'bytes must be a plain string, not %s' % type(bytes)
544
544
return self.put_file(relpath, StringIO(bytes), mode=mode)
546
def non_atomic_put(self, relpath, f, mode=None, create_parent_dir=False):
547
"""Copy the file-like object into the target location.
549
This function is not strictly safe to use. It is only meant to
550
be used when you already know that the target does not exist.
551
It is not safe, because it will open and truncate the remote
552
file. So there may be a time when the file has invalid contents.
554
:param relpath: The remote location to put the contents.
555
:param f: File-like object.
556
:param mode: Possible access permissions for new file.
557
None means do not set remote permissions.
558
:param create_parent_dir: If we cannot create the target file because
559
the parent directory does not exist, go ahead and
560
create it, and then try again.
562
# Default implementation just does an atomic put.
564
return self.put(relpath, f, mode=mode)
565
except errors.NoSuchFile:
566
if not create_parent_dir:
568
parent_dir = osutils.dirname(relpath)
570
self.mkdir(parent_dir)
571
return self.put(relpath, f, mode=mode)
546
573
@deprecated_method(zero_eleven)
547
574
def put_multi(self, files, mode=None, pb=None):
548
575
"""Put a set of files into the location.