Exemplo n.º 1
0
    def put(self, path, data, metadata={}, reduced_redundancy=False, encrypt_key=False, callback=None):
        """
        Stores data at given path
        :param string path: Path or 'key' for created/updated object
        :param bytes data: Data to write
        :param dict metadata: Metadata to store with this data
        :param bool reduced_redundancy: Whether to reduce storage redundancy or not?
        :param bool encrypt_key: Encrypt data?
        :param callable callback: Called function once done
        """
        storage_class = 'REDUCED_REDUNDANCY' if reduced_redundancy else 'STANDARD'

        args = dict(
            callback=callback,
            Bucket=self._bucket,
            Key=path,
            Body=data,
            Metadata=metadata,
            StorageClass=storage_class,
        )

        if encrypt_key:
            args['ServerSideEncryption'] = 'AES256'

        session = Botocore(service='s3', region_name=self._region, operation='PutObject')
        session.call(**args)
Exemplo n.º 2
0
    def put(self,
            path,
            data,
            metadata={},
            reduced_redundancy=False,
            encrypt_key=False,
            callback=None):
        """
        Stores data at given path
        :param string path: Path or 'key' for created/updated object
        :param bytes data: Data to write
        :param dict metadata: Metadata to store with this data
        :param bool reduced_redundancy: Whether to reduce storage redundancy or not?
        :param bool encrypt_key: Encrypt data?
        :param callable callback: Called function once done
        """
        storage_class = 'REDUCED_REDUNDANCY' if reduced_redundancy else 'STANDARD'

        args = dict(
            callback=callback,
            Bucket=self._bucket,
            Key=path,
            Body=data,
            Metadata=metadata,
            StorageClass=storage_class,
        )

        if encrypt_key:
            args['ServerSideEncryption'] = 'AES256'

        session = Botocore(service='s3',
                           region_name=self._region,
                           operation='PutObject')
        session.call(**args)
Exemplo n.º 3
0
 def delete(self, path, callback=None):
     """
     Deletes key at given path
     :param string path: Path or 'key' to delete
     :param callable callback: Called function once done
     """
     session = Botocore(service='s3', region_name=self._region, operation='DeleteObject')
     session.call(
         callback=callback,
         Bucket=self._bucket,
         Key=path,
     )
Exemplo n.º 4
0
 def get(self, path, callback=None):
     """
     Returns object at given path
     :param string path: Path or 'key' to retrieve AWS object
     :param callable callback: Callback function for once the retrieval is done
     """
     session = Botocore(service='s3', region_name=self._region, operation='GetObject')
     session.call(
         callback=callback,
         Bucket=self._bucket,
         Key=path,
     )
Exemplo n.º 5
0
 def get(self, path, callback=None):
     """
     Returns object at given path
     :param string path: Path or 'key' to retrieve AWS object
     :param callable callback: Callback function for once the retrieval is done
     """
     session = Botocore(service='s3',
                        region_name=self._region,
                        operation='GetObject')
     session.call(
         callback=callback,
         Bucket=self._bucket,
         Key=path,
     )
Exemplo n.º 6
0
 def delete(self, path, callback=None):
     """
     Deletes key at given path
     :param string path: Path or 'key' to delete
     :param callable callback: Called function once done
     """
     session = Botocore(service='s3',
                        region_name=self._region,
                        operation='DeleteObject')
     session.call(
         callback=callback,
         Bucket=self._bucket,
         Key=path,
     )