Why does the Amazon S3 Signed URL work locally, but not on the production server?

I would like to know why this method of the signed URL works locally, but not on a real server?

Locally, it gives out a URL that expires in 12 seconds, but on the server it returns an expired 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
source share
1 answer

The problem is resolved. It was a time zone issue. The problem can be resolved by correctly setting the time zone on both servers and / or taking into account the time difference.

+2
source

All Articles