22import math
33import os
44import requests
5+ import cryptography
6+ major , minor , patch = [int (x , 10 ) for x in cryptography .__version__ .split ('.' )]
7+ if major < 41 :
8+ from cryptography import CryptographyDeprecationWarning
9+ else :
10+ from cryptography .utils import CryptographyDeprecationWarning
511from pgpy import PGPMessage
612from sendsafely .Progress import Progress
13+ import warnings
714
815from sendsafely .exceptions import CreatePackageFailedException , FinalizePackageFailedException , DownloadFileException , \
916 UploadFileException , DeletePackageException , KeycodeRequiredException , GetPackageInformationFailedException , \
@@ -27,6 +34,7 @@ def __init__(self, sendsafely_instance, package_variables=None):
2734 :param package_variables:
2835 """
2936 super ().__init__ ()
37+ warnings .filterwarnings ('ignore' , category = CryptographyDeprecationWarning )
3038 self .initialized_via_keycode = True
3139 if package_variables is None :
3240 self .client_secret = _generate_keycode ()
@@ -283,11 +291,14 @@ def delete_file_from_package(self, file_id):
283291 raise DeleteFileException (details = response ["message" ])
284292 return response
285293
286- def get_file_information (self , file_id ):
294+ def get_file_information (self , file_id , directory_id = None ):
287295 """
288296 Return the file information for a specified fileId
289297 """
290- endpoint = "/package/" + self .package_id + "/file/" + file_id
298+ if directory_id :
299+ endpoint = "/package/" + self .package_id + "/directory/" + directory_id + "/file/" + file_id
300+ else :
301+ endpoint = "/package/" + self .package_id + "/file/" + file_id
291302 url = self .sendsafely .BASE_URL + endpoint
292303 headers = make_headers (self .sendsafely .API_SECRET , self .sendsafely .API_KEY , endpoint )
293304 response = requests .get (url = url , headers = headers ).json ()
@@ -300,7 +311,7 @@ def download_and_decrypt_file(self, file_id, directory_id=None, download_directo
300311 Downloads & decrypts the specified file to the path specified
301312 """
302313 self ._block_operation_without_keycode ()
303- file_info = self .get_file_information (file_id )
314+ file_info = self .get_file_information (file_id , directory_id )
304315 if not file_name :
305316 file_name = file_info ["fileName" ]
306317 total = file_info ["fileParts" ]
0 commit comments