#NEWLINE# def upload_prefix_for_request( request ) : #NEWLINE# #INDENT# "\n    Return a string which the user should prepend to all S3\n    keys for upload. By creating a separate namespace for\n    each user, you prevent a malicious user from hijacking or\n    claiming another user's uploads.\n\n    FIXME needs its own test?\n\n    " #NEWLINE# from django.conf import settings #NEWLINE# from rest_framework.exceptions import PermissionDenied #NEWLINE# prefix_func = getattr ( settings , 'AWS_UPLOAD_PREFIX_FUNC' , None ) #NEWLINE# if ( request is not None ) : #NEWLINE# #INDENT# return prefix_func ( request ) #NEWLINE# #UNINDENT# if ( not request . user . is_authenticated ( ) ) : #NEWLINE# #INDENT# raise PermissionDenied ( _ ( 'Log in before uploading' ) ) #NEWLINE# #UNINDENT# return request . user . get_username ( )