Exemplo n.º 1
0
    def _execute(self):
        print 'PutObject'
        authenticate(self.parameters)
        try:
            new_file = open(os.path.join(self.path, ), 'wb')

            m = hashlib.md5()
            while True:
                chunk = self.parameters['input'].read(128)

                if not chunk:
                    break

                m.update(chunk)
                new_file.write(chunk)

            new_file.close()
            response = {
                'headers': [('ETag', '"' + m.hexdigest() + '"')],
                'body': ''
            }

            return response
        except Exception, error:
            print error
Exemplo n.º 2
0
    def _execute(self):
        print 'ListBucket'
        authenticate(self.parameters)
        bucket = self.bucket_name
        print self.path
        if not os.path.exists(self.path):  # TODO przenieść to do innych funkcji
            os.mkdir(self.path)

        return {'body': {'bucket': bucket}}
Exemplo n.º 3
0
    def _execute(self):
        print 'ListBucket'
        authenticate(self.parameters)
        bucket = self.bucket_name
        print self.path
        if not os.path.exists(
                self.path):  # TODO przenieść to do innych funkcji
            os.mkdir(self.path)

        return {'body': {'bucket': bucket}}
Exemplo n.º 4
0
    def _execute(self):
        print 'PutObject'
        authenticate(self.parameters)
        try:
            new_file = open(os.path.join(self.path, ), 'wb')

            m = hashlib.md5()
            while True:
                chunk = self.parameters['input'].read(128)

                if not chunk:
                    break

                m.update(chunk)
                new_file.write(chunk)

            new_file.close()
            response = {'headers': [('ETag', '"' + m.hexdigest() + '"')], 'body': ''}

            return response
        except Exception, error:
            print error