(self, filename, uri, extra_headers = None, extra_label = "")
| 743 | return False |
| 744 | |
| 745 | def object_put(self, filename, uri, extra_headers = None, extra_label = ""): |
| 746 | # TODO TODO |
| 747 | # Make it consistent with stream-oriented object_get() |
| 748 | if uri.type != "s3": |
| 749 | raise ValueError("Expected URI type 's3', got '%s'" % uri.type) |
| 750 | |
| 751 | try: |
| 752 | is_dir = False |
| 753 | size = 0 |
| 754 | if filename == "-": |
| 755 | is_stream = True |
| 756 | src_stream = io.open(sys.stdin.fileno(), mode='rb', closefd=False) |
| 757 | src_stream.stream_name = u'<stdin>' |
| 758 | |
| 759 | else: |
| 760 | is_stream = False |
| 761 | filename_bytes = deunicodise(filename) |
| 762 | |
| 763 | stat = os.stat(filename_bytes) |
| 764 | mode = stat[ST_MODE] |
| 765 | |
| 766 | if S_ISDIR(mode): |
| 767 | is_dir = True |
| 768 | # Dirs are represented as empty objects on S3 |
| 769 | src_stream = io.BytesIO(b'') |
| 770 | elif not S_ISREG(mode): |
| 771 | raise InvalidFileError(u"Not a regular file") |
| 772 | else: |
| 773 | # Standard normal file |
| 774 | src_stream = io.open(filename_bytes, mode='rb') |
| 775 | size = stat[ST_SIZE] |
| 776 | src_stream.stream_name = filename |
| 777 | except (IOError, OSError) as e: |
| 778 | raise InvalidFileError(u"%s" % e.strerror) |
| 779 | |
| 780 | headers = SortedDict(ignore_case=True) |
| 781 | if extra_headers: |
| 782 | headers.update(extra_headers) |
| 783 | |
| 784 | ## Set server side encryption |
| 785 | if self.config.server_side_encryption: |
| 786 | headers["x-amz-server-side-encryption"] = "AES256" |
| 787 | |
| 788 | ## Set kms headers |
| 789 | if self.config.kms_key: |
| 790 | headers['x-amz-server-side-encryption'] = 'aws:kms' |
| 791 | headers['x-amz-server-side-encryption-aws-kms-key-id'] = self.config.kms_key |
| 792 | |
| 793 | ## MIME-type handling |
| 794 | headers["content-type"] = self.content_type(filename=filename, is_dir=is_dir) |
| 795 | |
| 796 | ## Other Amazon S3 attributes |
| 797 | if self.config.acl_public: |
| 798 | headers["x-amz-acl"] = "public-read" |
| 799 | headers["x-amz-storage-class"] = self.storage_class() |
| 800 | |
| 801 | ## Multipart decision |
| 802 | multipart = False |
nothing calls this directly
no test coverage detected