'This is the callback to os.path.walk and where much of the work happens'

def upload_s3(self, arg, dirname, names):

    (bucket, key, bucket_name, root_dir) = arg
    if (os.path.basename(dirname) in self.FILTER_LIST):
        del names[:]
        return
    if (not root_dir.endswith(os.path.sep)):
        root_dir = (root_dir + os.path.sep)
    for file in names:
        headers = {}
        if (file in self.FILTER_LIST):
            continue
        filename = os.path.join(dirname, file)
        if os.path.isdir(filename):
            continue
        file_key = filename[len(root_dir):]
        if self.prefix:
            file_key = ('%s/%s' % (self.prefix, file_key))
        if (not self.do_force):
            s3_key = bucket.get_key(file_key)
            if s3_key:
                s3_datetime = datetime.datetime(*time.strptime(s3_key.last_modified, '%a,    %d    %b    %Y    %H:%M:%S    %Z')[0:6])
                local_datetime = datetime.datetime.utcfromtimestamp(os.stat(filename).st_mtime)
                if (local_datetime < s3_datetime):
                    self.skip_count += 1
                    if (self.verbosity > 1):
                        print ("File    %s    hasn't    been    modified    since    last    being    uploaded" % file_key)
                    continue
        if (self.verbosity > 0):
            print ('Uploading    %s...' % file_key)
        content_type = mimetypes.guess_type(filename)[0]
        if content_type:
            headers['Content-Type'] = content_type
        else:
            headers['Content-Type'] = 'application/octet-stream'
        file_obj = open(filename, 'rb')
        file_size = os.fstat(file_obj.fileno()).st_size
        filedata = file_obj.read()
        if self.do_gzip:
            if ((file_size > 1024) and (content_type in self.GZIP_CONTENT_TYPES)):
                filedata = self.compress_string(filedata)
                if self.rename_gzip:
                    file_key = ('%s.%s' % (file_key, self.SYNC_S3_RENAME_GZIP_EXT))
                headers['Content-Encoding'] = 'gzip'
                if (self.verbosity > 1):
                    print (' DCTB gzipped:    %dk    to    %dk' % ((file_size / 1024), (len(filedata) / 1024)))
        if self.do_expires:
            headers['Expires'] = ('%s    GMT' % email.Utils.formatdate(time.mktime((datetime.datetime.now() + datetime.timedelta(days=(365 * 2))).timetuple())))
            headers['Cache-Control'] = ('max-age    %d' % (((3600 * 24) * 365) * 2))
            if (self.verbosity > 1):
                print (' DCTB expires:    %s' % headers['Expires'])
                print (' DCTB cache-control:    %s' % headers['Cache-Control'])
        try:
            key.name = file_key
            key.set_contents_from_string(filedata, headers, replace=True, policy=self.default_acl)
        except boto.exception.S3CreateError as e:
            print ('Failed:    %s' % e)
        except Exception as e:
            print e
            raise
        else:
            self.upload_count += 1
            self.uploaded_files.append(file_key)
        file_obj.close()
