Is it possible to get raw files at BitBucket?

GitHub offers direct access to files in public repositories by using a link like https://raw.github.com/user/repository/branch/filename. Using a link like this and CURL or WGET I may get a file in a public repository easily.

I recently moved some repositories I had at GitHub to BitBucket, since BitBucket offers me five private repositories for FREE, and FREE always seemed a lovely word for me. But it happens that I'm missing this feature in my public BitBucket repositories.

Is there a similar feature at BitBucket?

If so, what is the format of the URL to get a file?

Upvotes: 14

Views: 24677

Answers (3)

DevLeck
DevLeck

Reputation: 25

The UI steps to get the raw file appear to have changed, but when I'm looking at a certain branch or commit, I have to click the 3-dot menu at the top right of the file diff, then click "View entire file".

Once I'm at the file, I click its 3-dot menu and select "Open in Source". That should take you to a page with the committed file version, but that may not be easy to copy-paste if you need to.

To view just the file contents as text on a web page, click the 3-dot menu at the top right of the file path, then select "Open raw". This makes it easy to select all text or get the full path.

Upvotes: 0

gilad 1
gilad 1

Reputation: 99

it is easy to get plain text of any file using curl.

curl --user userName https://FQDN/repo_name/raw/fileName -o fileName

for example: URL for the target page in bitbucket: https://bitbucket.myDomain.com/projects/repos/repo/browse/myFile

will end with the following curl request: curl --user username https://bitbucket.myDomain.com/projects/repos/repo/raw/myFile -o targetFile

Upvotes: 6

pedrorijo91
pedrorijo91

Reputation: 7845

Yes. https://bitbucket.org/<account>/<repo-name>/raw/<commit-sha-or-HEAD>/<filename>

For this repo: https://bitbucket.org/pedrorijo91/hello-slick/src

Choose a a file (LICENSE for instance): https://bitbucket.org/pedrorijo91/hello-slick/src/fe7cfe392d8090fececdf481ba3a9270bbe678dd/LICENSE?fileviewer=file-view-default

and now click on the RAW button: https://bitbucket.org/pedrorijo91/hello-slick/raw/fe7cfe392d8090fececdf481ba3a9270bbe678dd/LICENSE

It seems bitbucket always adds a SHA before the file. You can specify the commit or HEAD seems to work also: https://bitbucket.org/pedrorijo91/hello-slick/raw/HEAD/LICENSE

Upvotes: 15

Related Questions