From 525ac1204594465e0a667207b52271a66fd6b5ea Mon Sep 17 00:00:00 2001 From: Paul D'Ambra Date: Fri, 14 Oct 2022 11:27:44 +0100 Subject: [PATCH] feat: markdown upload media (#12231) # Problem You can add gifs and images to text cards but need to know how to write markdown (and realise it is possible) # Changes * Adds an API (authenticated) to allow image upload * Adds an endpoint to view images (immutable cache headers set) * Adds some basic validation * Adds UI to allow drop of file onto a text card (well, any component using the LemonTextMarkdown) to upload the image and insert a link to it in the markdown content --- .run/PostHog.run.xml | 12 +- frontend/src/lib/api.ts | 11 ++ .../components/Cards/TextCard/TextCard.scss | 4 + .../LemonTextArea/LemonTextArea.scss | 6 + .../LemonTextArea/LemonTextArea.tsx | 132 ++++++++++++++++-- .../scenes/PreflightCheck/preflightLogic.tsx | 4 + frontend/src/types.ts | 6 + latest_migrations.manifest | 2 +- posthog/api/__init__.py | 2 + posthog/api/dashboard.py | 11 +- posthog/api/test/test_uploaded_media.py | 98 +++++++++++++ posthog/api/uploaded_media.py | 101 ++++++++++++++ posthog/migrations/0270_add_uploaded_media.py | 42 ++++++ posthog/models/__init__.py | 2 + posthog/models/uploaded_media.py | 71 ++++++++++ posthog/settings/object_storage.py | 1 + posthog/settings/web.py | 2 + posthog/urls.py | 2 + 18 files changed, 488 insertions(+), 21 deletions(-) create mode 100644 posthog/api/test/test_uploaded_media.py create mode 100644 posthog/api/uploaded_media.py create mode 100644 posthog/migrations/0270_add_uploaded_media.py create mode 100644 posthog/models/uploaded_media.py diff --git a/.run/PostHog.run.xml b/.run/PostHog.run.xml index 3f9cfc21a8e..7f4cfc9c346 100644 --- a/.run/PostHog.run.xml +++ b/.run/PostHog.run.xml @@ -4,14 +4,14 @@