def ad_image_upload(instance, filename): new_filename = uuid.uuid4() name, ext = get_filename_ext(filename) image_name = '{new_filename}{ext}'.format(new_filename=new_filename, ext=ext) return "image/ad/{location}/{image_name}".format( location=instance.location, image_name=image_name)
def post_video_upload(instance, filename): new_filename = uuid.uuid4() name, ext = get_filename_ext(filename) video_name = '{new_filename}{ext}'.format(new_filename=new_filename, ext=ext) return 'video/post/{post_id}/{video_name}'.format(post_id=instance.post.id, video_name=video_name)
def user_pic_upload(instance, filename): new_filename = uuid.uuid4() name, ext = get_filename_ext(filename) image_name = '{new_filename}{ext}'.format(new_filename=new_filename, ext=ext) return "image/account/{username}/{image_name}".format( username=instance.owner.username, image_name=image_name )
def post_image_upload(instance, filename): # new_filename = random.randint(1111111111, 9999999999) new_filename = uuid.uuid4() name, ext = get_filename_ext(filename) img_name = '{new_filename}{ext}'.format(new_filename=new_filename, ext=ext) # return 'image/post/{img_name}'.format(img_name=img_name) return 'image/post/{post_id}/{img_name}'.format(post_id=instance.post.id, img_name=img_name)
def third_user_pic_upload(instance, filename): new_filename = uuid.uuid4() name, ext = get_filename_ext(filename) final_filename = '{new_filename}{ext}'.format(new_filename=new_filename, ext=ext) return "image/third_login/{final_filename}".format(final_filename=final_filename)