def generate_download_url(self):
		bucket = getattr(settings, 'AWS_STORAGE_BUCKET_NAME')
		region = getattr(settings, 'S3DIRECT_REGION')
		access_key = getattr(settings, 'AWS_ACCESS_KEY_ID')
		secret_key = getattr(settings, 'AWS_SECRET_ACCESS_KEY')
		PROTECTED_DIR_NAME = getattr(settings, 'PROTECTED_DIR_NAME')
		path = '{base}/{file}'.format(base=PROTECTED_DIR_NAME, file=str(self.file))
		if not bucket or not region or not access_key or not secret_key:
			return '/'
		aws_dl_object =  AWSDownload(access_key, secret_key, bucket, region)
		file_url = aws_dl_object.generate_url(path, new_filename=self.display_name)
		return file_url
Exemple #2
0
	def generate_download_url(self):
		bucket = getattr(settings, 'AWS_STORAGE_BUCKET_NAME')
		region = getattr(settings, 'S3DIRECT_REGION')
		access_key = getattr(settings, 'AWS_ACCESS_KEY_ID')
		secret_key = getattr(settings, 'AWS_SECRET_ACCESS_KEY')
		if not secret_key or not access_key or not bucket or not region:
			return "/product-not-found/"
		PROTECTED_DIR_NAME = getattr(settings, 'PROTECTED_DIR_NAME', 'protected')
		path = "{base}/{file_path}".format(base=PROTECTED_DIR_NAME, file_path=str(self.file))
		aws_dl_object =  AWSDownload(access_key, secret_key, bucket, region)
		file_url = aws_dl_object.generate_url(path,new_filename=self.display_name)#, new_filename='New awesome file')
		return file_url
Exemple #3
0
 def generate_download_url(self):
     bucket = getattr(settings, 'AWS_STORAGE_BUCKET_NAME')
     region = getattr(settings, 'S3DIRECT_REGION')
     access_key = getattr(settings, 'AWS_ACCESS_KEY_ID')
     secret_key = getattr(settings, 'AWS_SECRET_ACCESS_KEY')
     if not access_key or not secret_key or not bucket or not region:
         return '/product_not_found/'
     protected_dir_name = getattr(settings, 'PROTECTED_DIR_NAME',
                                  'protected')
     path = f'{protected_dir_name}/{str(self.file)}'  # works for any path inside bucket
     aws_dl_object = AWSDownload(access_key, secret_key, bucket, region)
     file_url = aws_dl_object.generate_url(path,
                                           new_filename=self.display_name)
     return file_url
Exemple #4
0
	def generate_download_url(self):
		bucket = getattr(settings, "AWS_STORAGE_BUCKET_NAME")
		region = getattr(settings,"S3DIRECT_REGION")
		access_key = getattr(settings,"AWS_ACCESS_KEY_ID")
		secret_key = getattr(settings,"AWS_SECRET_ACCESS_KEY")
		if not secret_key or not access_key or not bucket or not region:
			print("Ca ne marche pas")
			return "/product-not-found/"
		PROTECTED_DIR_NAME = getattr(settings, "PROTECTED_DIR_NAME", "protected" )
		path ="{base}/{file_path}".format(base=PROTECTED_DIR_NAME, file_path=str(self.file))
		print(path)

		aws_dl_object =  AWSDownload(access_key=access_key, secret_key=secret_key, bucket=bucket, region=region)
		file_url = aws_dl_object.generate_url(path, self.display_name) #,new_filename='New awesome file')
		return file_url
Exemple #5
0
    def generate_download_url(self):
        bucket = getattr(settings, "AWS_STORAGE_BUCKET_NAME")
        region = getattr(settings, "AWS_S3_REGION_NAME")
        access_key = getattr(settings, "AWS_ACCESS_KEY_ID")
        secret_key = getattr(settings, "AWS_SECRET_ACCESS_KEY")
        if not secret_key or not access_key or not bucket or not region:
            return "/product-not-found/"
        PROTECTED_DIR_NAME = getattr(settings, "PROTECTED_DIR_NAME")
        path = '{base}/{file_path}'.format(base=PROTECTED_DIR_NAME,
                                           file_path=str(self.file))

        aws_dl_object = AWSDownload(access_key, secret_key, bucket, region)
        file_url = aws_dl_object.generate_url(path,
                                              new_filename=self.display_name)
        return file_url