Skip to content

Commit

Permalink
Merge pull request #2 from silentworks/develop
Browse files Browse the repository at this point in the history
Update for featured image to not download
  • Loading branch information
silentworks committed Sep 29, 2023
2 parents 8b4ab10 + c6ea153 commit d05b636
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
5 changes: 1 addition & 4 deletions app/notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,8 @@ def edit(note_id):
if note["featured_image"] is not None:
r = supabase.storage.from_("featured_image").get_public_url(
note["featured_image"],
options={"transform": {"width": 200}, "download": True},
options={"transform": {"width": 200}},
)
# image = f"data:image/png;base64," + base64.b64encode(r).decode("utf-8")
image = r
else:
path = note["featured_image"]
Expand All @@ -103,13 +102,11 @@ def edit(note_id):
content = form.content.data
is_public = form.is_public.data
featured_image = form.featured_image.name
print(f"Featured: {featured_image}")
if featured_image is not None:
image = request.files[featured_image]
image_stream = io.BytesIO()
image.save(image_stream)
path = f"{profile['id']}/{random_choice().lower()}_fi.png"
print(f"Path: {path}")

try:
if featured_image is not None:
Expand Down
4 changes: 2 additions & 2 deletions supabase/migrations/20230924205231_add_notes.sql
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ to authenticated
using (auth.uid() = author_id);

-- Set up storage for featured_images
insert into storage.buckets (id, name)
values ('featured_image', 'featured_image');
insert into storage.buckets (id, name, public)
values ('featured_image', 'featured_image', true);

-- Set up access controls for storage.
-- See https://supabase.com/docs/guides/storage#policy-examples for more details.
Expand Down

0 comments on commit d05b636

Please sign in to comment.