@@ -211,6 +211,63 @@ def download_content(self, subject, repo, remote_file_path, local_file_path):
211211 self ._logger .info ("Download successfully: {}" .format (url ))
212212 return response
213213
214+ def dynamic_download (self , subject , repo , remote_file_path , local_file_path , bt_package = None ):
215+ """ Download a file based on a dynamic file_path .
216+
217+ This resource is only available for Bintray Premium repositories.
218+
219+ Currently, only the $latest token is supported, which is useful for downloading the
220+ latest file published under a specified package.
221+
222+ Package name can be supplied as a:
223+ The bt_package query parameter
224+ The bt_package matrix parameter
225+ The X-Bintray-Package request header
226+
227+ A successful call will return a 302 redirect to a generated signed URL
228+ (with 15 second expiry) to the resolved file path.
229+
230+ :param subject: username or organization
231+ :param repo: repository name
232+ :param remote_file_path: file name to be downloaded from Bintray
233+ :param local_file_path: file name to be stored in local storage
234+ :param bt_package: query parameter
235+ """
236+
237+ parameters = {"bt_package" : bt_package } if bt_package else None
238+ download_base_url = "https://dl.bintray.com"
239+ url = "{}/{}/{}/{}" .format (download_base_url , subject , repo , remote_file_path )
240+ response , content = self ._requester .download (url , params = parameters )
241+
242+ with open (local_file_path , 'wb' ) as local_fd :
243+ local_fd .write (content )
244+
245+ self ._logger .info ("Download successfully: {}" .format (url ))
246+ return response
247+
248+ def url_signing (self , subject , repo , file_path , json_data , encrypt = False ):
249+ """ Generates an anonymous, signed download URL with an expiry date.
250+
251+ Caller must be an owner of the repository or a publisher in the organization owning
252+ the repository.
253+
254+ Encrypted download is possible - encryption will be done using AES 256 CBC, see below
255+ documentation.
256+
257+ This resource is only available to Bintray Premium users.
258+
259+ :param subject: username or organization
260+ :param repo: repository name
261+ :param file_path: signed path
262+ :param json_data: URL data
263+ :param encrypt: encrypted download
264+ """
265+
266+ parameters = {"encrypt" : str (encrypt ).lower ()}
267+ url = "{}/signed_url/{}/{}/{}" .format (Bintray .BINTRAY_URL , subject , repo , file_path )
268+ response = self ._requester .post (url , json = json_data , params = parameters )
269+ return response
270+
214271 # Licenses
215272
216273 def get_org_proprietary_licenses (self , org ):
0 commit comments