- removed responsible
Private Repo - Downloadable zip link?
Hello,
Can you guys help me creating a download link to any Bitbucket private repository with this APIs? I'm trying to update a Wordpress plugin via Bitbucket. I can get a single file content with "raw()" function in "Repository" class, but I couldn't create the zipball link that Wordpress core can pull the zip file and unpack it.
I hope I could explained my request clearly. Thanks in advance..
Comments (7)
-
reporter -
You can use the following URL template to download an archive of your repository:
https://bitbucket.org/<team>/<repo>/get/<sha1>.(zip|gz|bz2)
For example, to download the current version of
bitbucket-api
library, you can access the following URL: https://bitbucket.org/gentlero/bitbucket-api/get/2a3d5b006452.zipYou can also tag a release and use the same link template to download it:
https://bitbucket.org/<team>/<repo>/get/<tag>.(zip|gz|bz2)
ex: https://bitbucket.org/gentlero/bitbucket-api/get/0.8.0.zip
You can also vote for BB-3711. Maybe it will be implemented in the future.
-
reporter I can download files with these links only if it's a public repository, isn't it? Am I able to download private zip files with these link templates without any authorization? If I need to authorize, can you please give me a php code example to create Authorized Private Repo Link if possible? Like in your examples:
$bitbucket = new \Bitbucket\API\Api(); $user->getClient()->addListener( new Bitbucket\API\Http\Listener\OAuthListener($oauth_params) ); $authorized_link = $bitbucket->api('{Appropriate}\{Class}')->maybe_necessary_function_to_do_it();
It's done with adding a query string to the link in Github. But, I couldn't find any way to do it in Bitbucket yet.
For Github:
$zipball_url = "https://github.com/<team>/<repo>/archive/<master|tag>.zip"; if( $authorize_token ) { // Is there an access token? $zipball_url = add_query_arg( 'access_token', $authorize_token, $zipball_url ); // Update our zip url with token }
-
There is no API endpoint for downloads (see issue BB-3711 that I also linked in my previous answer), so you can't use this client to download an archive.
I can download files with these links only if it's a public repository, isn't it?
You can download from private repositories also, but you need to sign in using Basic HTTP:
curl_setopt($process, CURLOPT_USERPWD, $username . ":" . $password);
But I don't recommend doing this from a Wordpress plugin, because your Bitbucket credentials will be at risk.
You should store the archives somewhere else, where you can have the possibility to manage permissions in a more secure way, or write (and host) your own proxy which will make connection between each Wordpress installation and Bitbucket in a secure way (OAuth2, short TTL tokens per each WP install, etc).
-
reporter Okay, thanks for the information!
-
reporter - changed status to wontfix
-
It is now implemented.
- Log in to comment