我想知道是什么原因导致这个签名的 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))