示例#1
0
    def _uploadfile(self, fn, data=None):
        """Uploads a file to Amazon S3.

        Arguments:
        fn -- file name to upload
        data -- contents of file to upload, if not stored in file at fn

        Returns the URL of the now-uploaded file.

        """
        key = Key(self.bucket, fn)
        if data:
            key.path = fn
            key.set_contents_from_string(data, policy='public-read')
        else:
            key.set_contents_from_filename(fn, policy='public-read')
        url = key.generate_url(86400, force_http=True, query_auth=False).replace(':433', '')
        return url