22import math
33import os
44import requests
5+ from cryptography import CryptographyDeprecationWarning
56from pgpy import PGPMessage
67from sendsafely .Progress import Progress
8+ import warnings
79
810from sendsafely .exceptions import CreatePackageFailedException , FinalizePackageFailedException , DownloadFileException , \
911 UploadFileException , DeletePackageException , KeycodeRequiredException , GetPackageInformationFailedException , \
@@ -27,6 +29,7 @@ def __init__(self, sendsafely_instance, package_variables=None):
2729 :param package_variables:
2830 """
2931 super ().__init__ ()
32+ warnings .filterwarnings ('ignore' , category = CryptographyDeprecationWarning )
3033 self .initialized_via_keycode = True
3134 if package_variables is None :
3235 self .client_secret = _generate_keycode ()
@@ -283,11 +286,14 @@ def delete_file_from_package(self, file_id):
283286 raise DeleteFileException (details = response ["message" ])
284287 return response
285288
286- def get_file_information (self , file_id ):
289+ def get_file_information (self , file_id , directory_id = None ):
287290 """
288291 Return the file information for a specified fileId
289292 """
290- endpoint = "/package/" + self .package_id + "/file/" + file_id
293+ if directory_id :
294+ endpoint = "/package/" + self .package_id + "/directory/" + directory_id + "/file/" + file_id
295+ else :
296+ endpoint = "/package/" + self .package_id + "/file/" + file_id
291297 url = self .sendsafely .BASE_URL + endpoint
292298 headers = make_headers (self .sendsafely .API_SECRET , self .sendsafely .API_KEY , endpoint )
293299 response = requests .get (url = url , headers = headers ).json ()
@@ -300,7 +306,7 @@ def download_and_decrypt_file(self, file_id, directory_id=None, download_directo
300306 Downloads & decrypts the specified file to the path specified
301307 """
302308 self ._block_operation_without_keycode ()
303- file_info = self .get_file_information (file_id )
309+ file_info = self .get_file_information (file_id , directory_id )
304310 if not file_name :
305311 file_name = file_info ["fileName" ]
306312 total = file_info ["fileParts" ]
0 commit comments