Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/pip/main/pre-commit-3.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mansueli authored Feb 28, 2024
2 parents d139010 + 5db5fd2 commit 119e1e7
Show file tree
Hide file tree
Showing 12 changed files with 374 additions and 40 deletions.
5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
target-branch: "main"
- package-ecosystem: "pip"
directory: "/"
schedule:
Expand Down
18 changes: 12 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: CI/CD

on: [pull_request, push, workflow_dispatch]
on:
push:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
test:
Expand All @@ -12,15 +17,15 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Clone Repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Set up Poetry
uses: abatilo/actions-poetry@v2.2.0
uses: abatilo/actions-poetry@v3.0.0
with:
poetry-version: 1.3.2

Expand All @@ -31,7 +36,7 @@ jobs:
uses: codecov/codecov-action@v1
publish:
needs: test
if: ${{ !startsWith(github.event.head_commit.message, 'bump') && !startsWith(github.event.head_commit.message, 'chore') && github.ref == 'refs/heads/main' && github.event_name == 'push' && github.repository_owner == 'supabase-community' }}
if: ${{ !startsWith(github.event.head_commit.message, 'bump') && !startsWith(github.event.head_commit.message, 'chore') && github.ref == 'refs/heads/main' && contains(fromJSON('["push", "workflow_dispatch"]'), github.event_name) && github.repository_owner == 'supabase-community' }}
runs-on: ubuntu-latest
name: "Bump version, create changelog and publish"
environment:
Expand All @@ -42,10 +47,11 @@ jobs:
contents: write # needed for github actions bot to write to repo
steps:
- name: Clone Repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
fetch-depth: 0
token: ${{ secrets.SILENTWORKS_PAT }}
- name: Python Semantic Release
id: release
uses: python-semantic-release/python-semantic-release@v8.0.0
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -56,7 +56,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
Expand All @@ -69,6 +69,6 @@ jobs:
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
2 changes: 1 addition & 1 deletion .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v2
- uses: actions/setup-python@v5
- uses: actions/checkout@master
with:
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
Expand Down
82 changes: 82 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,88 @@



## v0.7.0 (2023-11-22)

### Chore

* chore: update GitHub workflow for releases ([`72ad275`](https://github.com/supabase-community/storage-py/commit/72ad2752849621446fd1df7ebc0b85dc4d9cf4cd))

* chore: add sync version of the update function ([`18c14a4`](https://github.com/supabase-community/storage-py/commit/18c14a4e7888cd14d09b7cbbd2e8b02f9cef02f0))

* chore(deps-dev): bump pytest from 7.4.2 to 7.4.3

Bumps [pytest](https://github.com/pytest-dev/pytest) from 7.4.2 to 7.4.3.
- [Release notes](https://github.com/pytest-dev/pytest/releases)
- [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest/compare/7.4.2...7.4.3)

---
updated-dependencies:
- dependency-name: pytest
dependency-type: direct:development
update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com> ([`87125bc`](https://github.com/supabase-community/storage-py/commit/87125bccaee9eeffd136af5ee8c442a4161b4761))

* chore(deps-dev): bump black from 23.9.1 to 23.10.0

Bumps [black](https://github.com/psf/black) from 23.9.1 to 23.10.0.
- [Release notes](https://github.com/psf/black/releases)
- [Changelog](https://github.com/psf/black/blob/main/CHANGES.md)
- [Commits](https://github.com/psf/black/compare/23.9.1...23.10.0)

---
updated-dependencies:
- dependency-name: black
dependency-type: direct:development
update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com> ([`ac6f901`](https://github.com/supabase-community/storage-py/commit/ac6f9017d8cde34b930b0436af5f413fc589b12f))

* chore(deps-dev): bump urllib3 from 2.0.5 to 2.0.7

Bumps [urllib3](https://github.com/urllib3/urllib3) from 2.0.5 to 2.0.7.
- [Release notes](https://github.com/urllib3/urllib3/releases)
- [Changelog](https://github.com/urllib3/urllib3/blob/main/CHANGES.rst)
- [Commits](https://github.com/urllib3/urllib3/compare/v2.0.5...2.0.7)

---
updated-dependencies:
- dependency-name: urllib3
dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com> ([`79c9ca3`](https://github.com/supabase-community/storage-py/commit/79c9ca3b23e13e7f1d3788edc99d5939f59d0960))

### Feature

* feat: add update existing file function ([`da4d785`](https://github.com/supabase-community/storage-py/commit/da4d785028e86899f1efc23394883836b94cd0d3))

### Unknown

* Merge pull request #166 from supabase-community/chore/update-gh-workflow

chore: update GitHub workflow for releases ([`f42d176`](https://github.com/supabase-community/storage-py/commit/f42d1766d4a8649a995ae474185eb50d0572bf2c))

* Merge pull request #165 from supabase-community/silentworks/file_update

feat: add update existing file function ([`d8139e0`](https://github.com/supabase-community/storage-py/commit/d8139e0e36f5d083262e61809e74313969de7996))

* Merge pull request #158 from supabase-community/dependabot/pip/urllib3-2.0.7

chore(deps-dev): bump urllib3 from 2.0.5 to 2.0.7 ([`fc8cb5d`](https://github.com/supabase-community/storage-py/commit/fc8cb5d60511d3e795614ff17facebe22b6f93f2))

* Merge pull request #162 from supabase-community/dependabot/pip/main/pytest-7.4.3

chore(deps-dev): bump pytest from 7.4.2 to 7.4.3 ([`9b048cb`](https://github.com/supabase-community/storage-py/commit/9b048cbb913b725f326e1c3e8eaa4b9377b6f1d6))

* Merge pull request #159 from supabase-community/dependabot/pip/main/black-23.10.0

chore(deps-dev): bump black from 23.9.1 to 23.10.0 ([`0f332fa`](https://github.com/supabase-community/storage-py/commit/0f332fa714636f343deb390ec58a288563fc81d2))


## v0.6.1 (2023-10-02)

### Documentation
Expand Down
6 changes: 4 additions & 2 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ See CONTRIBUTING.md for general contribution guidelines.
# Maintainers (in alphabetical order)

- [anand2312](https://github.com/anand2312)


# Emeritus Maintainers (in alphabetical order)
- [dreinon](https://github.com/dreinon)
- [fedden](https://github.com/fedden)
- [J0](https://github.com/J0)
- [leynier](https://github.com/leynier)

# Emeritus Maintainers (in alphabetical order)

- [fedden](https://github.com/fedden)
27 changes: 14 additions & 13 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ license = "MIT"
name = "storage3"
readme = "README.md"
repository = "https://github.com/supabase-community/storage-py"
version = "0.6.1"
version = "0.7.0"

[tool.poetry.dependencies]
httpx = ">=0.24,<0.26"
Expand All @@ -27,7 +27,7 @@ typing-extensions = "^4.2.0"
python-dateutil = "^2.8.2"

[tool.poetry.dev-dependencies]
python-semantic-release = "^8.1.1"
python-semantic-release = "^9.1.1"
black = "^23.10.0"
isort = "^5.12.0"
pre-commit = "^3.5.0"
Expand Down
43 changes: 37 additions & 6 deletions storage3/_async/file_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from dataclasses import dataclass, field
from io import BufferedReader, FileIO
from pathlib import Path
from typing import Any, Optional, Union, cast
from typing import Any, Literal, Optional, Union, cast

from httpx import HTTPError, Response

Expand Down Expand Up @@ -344,8 +344,9 @@ async def download(self, path: str, options: DownloadOptions = {}) -> bytes:
)
return response.content

async def upload(
async def _upload_or_update(
self,
method: Literal["POST", "PUT"],
path: str,
file: Union[BufferedReader, bytes, FileIO, str, Path],
file_options: Optional[FileOptions] = None,
Expand All @@ -367,9 +368,6 @@ async def upload(
file_options = {}
cache_control = file_options.get("cache-control")
_data = {}
if cache_control:
file_options["cache-control"] = f"max-age={cache_control}"
_data = {"cacheControl": cache_control}

headers = {
**self._client.headers,
Expand All @@ -378,6 +376,10 @@ async def upload(
}
filename = path.rsplit("/", maxsplit=1)[-1]

if cache_control:
headers["cache-control"] = f"max-age={cache_control}"
_data = {"cacheControl": cache_control}

if (
isinstance(file, BufferedReader)
or isinstance(file, bytes)
Expand All @@ -398,9 +400,38 @@ async def upload(
_path = self._get_final_path(path)

return await self._request(
"POST", f"/object/{_path}", files=files, headers=headers, data=_data
method, f"/object/{_path}", files=files, headers=headers, data=_data
)

async def upload(
self,
path: str,
file: Union[BufferedReader, bytes, FileIO, str, Path],
file_options: Optional[FileOptions] = None,
) -> Response:
"""
Uploads a file to an existing bucket.
Parameters
----------
path
The relative file path including the bucket ID. Should be of the format `bucket/folder/subfolder/filename.png`.
The bucket must already exist before attempting to upload.
file
The File object to be stored in the bucket. or a async generator of chunks
file_options
HTTP headers.
"""
return await self._upload_or_update("POST", path, file, file_options)

async def update(
self,
path: str,
file: Union[BufferedReader, bytes, FileIO, str, Path],
file_options: Optional[FileOptions] = None,
) -> Response:
return await self._upload_or_update("PUT", path, file, file_options)

def _get_final_path(self, path: str) -> str:
return f"{self.id}/{path}"

Expand Down
Loading

0 comments on commit 119e1e7

Please sign in to comment.