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