Skip to content

Feature Request: WriteFileBlob doesn't implement raw content format #314

@kuzminT

Description

@kuzminT

I was working with pushing file changes to bitbucket and noticed that go-bitbucket only has one method for this - WriteFileBlob() - which requires a real file to send the request. However, Bitbucket API also supports URL-encoded format to send raw content without creating temporary files (which is useful when you don't have actual files, as in my case).

Current Workaround

Currently, to send raw content, you need to:

  1. Create a temporary file.
  2. Write content to it.
  3. Use WriteFileBlob().
  4. Clean up the temporary file.

This is inefficient and unnecessary when you already have raw content in memory.

Proposed Solution

The Bitbucket API supports URL-encoded format for sending raw content directly:

$ curl https://api.bitbucket.org/2.0/repositories/atlassian/bbql/src \
  --data-urlencode "/path/to/me.txt=Lorem ipsum." \
  --data-urlencode "message=Initial commit" \
  --data-urlencode "author=Erik van Zijst <[email protected]>"

I've tested this via curl and it works well.

Suggestions:

Add a new method like WriteFileContent() or WriteFileRawContent() that accepts raw content as a parameter.
Alternative: Extend the existing WriteFileBlob() method to support both file paths and raw content.

Also WriteFileBlob() method currently has no documentation or test coverage, which makes it harder to discover and use correctly.

Thanks again for maintaining this project!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions