Had to swap to minio to let it act as a cdn. Working file uploads.
This commit is contained in:
@@ -37,7 +37,7 @@ function timeAgo(): string {
|
||||
|
||||
function getAssetHost(): string {
|
||||
const appEl = document.getElementById("app");
|
||||
return appEl?.dataset.assetHost ?? "http://localhost:3901";
|
||||
return appEl?.dataset.assetHost ?? "http://localhost:9000";
|
||||
}
|
||||
|
||||
// ── Components ─────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -10,7 +10,7 @@ import Config
|
||||
config :waffle,
|
||||
storage: Waffle.Storage.S3,
|
||||
bucket: "mixer-bucket",
|
||||
asset_host: "http://localhost:3900"
|
||||
asset_host: "http://localhost:9000"
|
||||
|
||||
config :ex_aws,
|
||||
json_codec: Jason
|
||||
|
||||
@@ -92,15 +92,13 @@ config :phoenix_live_view,
|
||||
# Disable swoosh api client as it is only required for production adapters.
|
||||
config :swoosh, :api_client, false
|
||||
|
||||
# Local S3-compatible storage (MinIO or similar at localhost:3901)
|
||||
# Adjust access_key_id / secret_access_key to match your local server's credentials
|
||||
# Local S3-compatible storage (MinIO at localhost:9000)
|
||||
config :ex_aws,
|
||||
access_key_id: "GKdea8f62997a90ffa664135d2",
|
||||
secret_access_key: "dd2f1757661a9e68cae6928a2fc950a2b2fd03b229d71038c98d4713b40ebba2",
|
||||
region: "garage"
|
||||
access_key_id: "minioadmin",
|
||||
secret_access_key: "minioadmin"
|
||||
|
||||
config :ex_aws, :s3,
|
||||
scheme: "http://",
|
||||
host: "localhost",
|
||||
port: 3900,
|
||||
region: "garage"
|
||||
port: 9000,
|
||||
virtual_host: false
|
||||
|
||||
@@ -13,7 +13,7 @@ defmodule Mixer.Posts.MediaUploader do
|
||||
def storage_dir(_version, {_file, scope}), do: "uploads/media/#{scope.id}"
|
||||
|
||||
def filename(_version, {file, _scope}) do
|
||||
Path.basename(file.file_name)
|
||||
Path.basename(file.file_name, Path.extname(file.file_name))
|
||||
end
|
||||
|
||||
def s3_object_headers(_version, {file, _scope}) do
|
||||
|
||||
@@ -6,8 +6,14 @@ defmodule MixerWeb.PageController do
|
||||
end
|
||||
|
||||
def index(conn, _params) do
|
||||
asset_host = Application.get_env(:waffle, :asset_host, "http://localhost:3900")
|
||||
bucket = Application.get_env(:waffle, :bucket, "mixer-bucket")
|
||||
|
||||
conn
|
||||
|> put_root_layout(html: {MixerWeb.Layouts, :spa_root})
|
||||
|> render(:index, current_user: conn.assigns[:current_user])
|
||||
|> render(:index,
|
||||
current_user: conn.assigns[:current_user],
|
||||
media_host: "#{asset_host}/#{bucket}"
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<div id="app"
|
||||
data-current-user-id={if @current_user, do: @current_user.id, else: ""}
|
||||
data-current-user-email={if @current_user, do: @current_user.email, else: ""}>
|
||||
data-current-user-email={if @current_user, do: @current_user.email, else: ""}
|
||||
data-asset-host={@media_host}>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user