VOOZH about

URL: https://qiita.com/k-yamada-github/items/1c7422f1c2c0e2d6fdb9

⇱ bitbucketのAPIを使って、ダウンロードファイルの作成/取得を行う #Bitbucket - Qiita


👁 Image
4

Go to list of users who liked

4

Share on X(Twitter)

Share on Facebook

Add to Hatena Bookmark

More than 5 years have passed since last update.

@k-yamada-githubin👁 Image
株式会社ソニックス

bitbucketのAPIを使って、ダウンロードファイルの作成/取得を行う

4
Posted at

bitbucketのAPIを使って、ダウンロードファイルの作成と取得を行うことができます。
これを利用すれば、例えばバイナリファイルのデプロイを行うことができます。

アプリパスワードの作成

APIの認証にはBasic認証を使うことも出来ますが、パスワードを晒したくない場合はアプリパスワードで認証することをお勧めします。
以下のリンクを参考に、アプリパスワードを作成してください。
また、ダウンロードファイルのAPIを利用するため、リポジトリの書き込み権限を付与してください。

ダウンロードファイル作成

POST /2.0/repositories/{username}/{repo_slug}/downloads

$ echo Hello World > hello.txt
$ curl --user $USER_ID:$APP_PASSWORD -X POST https://api.bitbucket.org/2.0/repositories/evzijst/git-tests/downloads -F files=@hello.txt

ダウンロードファイル取得

GET /2.0/repositories/{username}/{repo_slug}/downloads/{filename}

$ curl --user $USER_ID:$APP_PASSWORD -L https://api.bitbucket.org/2.0/repositories/evzijst/git-tests/downloads/hello.txt
Hello World
4

Go to list of users who liked

4
0

Go to list of comments

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4

Go to list of users who liked

4