4

我想知道是什么原因导致这个签名的 URL 方法在本地工作但不能在真实服务器中工作?

在本地它会产生一个在 12 秒后过期的 URL,但在服务器中它返回一个过期的 URL?

def s3_signed_url(file_path):
    import boto
    s3conn = boto.connect_s3(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
    bucket = s3conn.get_bucket(BUCKET_NAME, validate=False)
    key = bucket.new_key(file_path)
    signed_url = key.generate_url(expires_in=12)
    return signed_url



@never_cache
def enjoy_the_show(request, movie_id):
    m = get_object_or_404(Movie, pk=movie_id)
    iOS = is_ios_device(request)
    if (iOS is True):
        movie_path = m.m3u8_url
        movie_path = movie_path.replace('https://s3.amazonaws.com/domain.com','')
        signed_url = s3_signed_url(movie_path)
        return render_to_response('movies/enjoy_show_iOS.html', {'signed_url':signed_url,'movie': m,'is_logged_in':is_logged_in(request)},context_instance=RequestContext(request))
    else:
        return render_to_response('movies/enjoy_show.html', {'movie': m,'is_logged_in':is_logged_in(request)},context_instance=RequestContext(request))
4

1 回答 1

2

问题解决了。这是一个时区问题。可以通过在两台服务器上正确配置时区和/或考虑时差来解决此问题。

于 2012-06-30T20:21:05.860 回答