[backport cloud/1.38] fix: include subfolder in asset download URL for audio/video files (#8685)

Backport of #8684 to `cloud/1.38`

Automatically created by backport workflow.

Co-authored-by: Johnpaul Chiwetelu <49923152+Myestery@users.noreply.github.com>
This commit is contained in:
Comfy Org PR Bot
2026-02-06 13:27:09 +09:00
committed by GitHub
parent a51ba16e5a
commit 155548c1b8
2 changed files with 13 additions and 22 deletions

View File

@@ -65,15 +65,8 @@ export function useMediaAssetActions() {
try {
const filename = targetAsset.name
let downloadUrl: string
// In cloud, use preview_url directly (from cloud storage)
// In OSS/localhost, use the /view endpoint
if (isCloud && targetAsset.preview_url) {
downloadUrl = targetAsset.preview_url
} else {
downloadUrl = getAssetUrl(targetAsset)
}
// Prefer preview_url (already includes subfolder) with getAssetUrl as fallback
const downloadUrl = targetAsset.preview_url || getAssetUrl(targetAsset)
downloadFile(downloadUrl, filename)
@@ -103,15 +96,8 @@ export function useMediaAssetActions() {
try {
assets.forEach((asset) => {
const filename = asset.name
let downloadUrl: string
// In cloud, use preview_url directly (from GCS or other cloud storage)
// In OSS/localhost, use the /view endpoint
if (isCloud && asset.preview_url) {
downloadUrl = asset.preview_url
} else {
downloadUrl = getAssetUrl(asset)
}
// Prefer preview_url (already includes subfolder) with getAssetUrl as fallback
const downloadUrl = asset.preview_url || getAssetUrl(asset)
downloadFile(downloadUrl, filename)
})

View File

@@ -8,7 +8,7 @@ import { getAssetType } from './assetTypeUtil'
/**
* Get the download/view URL for an asset
* Constructs the proper URL with filename encoding and type parameter
* Constructs the proper URL with filename encoding, type, and subfolder parameters
*
* @param asset The asset to get URL for
* @param defaultType Default type if asset doesn't have tags (default: 'output')
@@ -23,7 +23,12 @@ export function getAssetUrl(
defaultType: 'input' | 'output' = 'output'
): string {
const assetType = getAssetType(asset, defaultType)
return api.apiURL(
`/view?filename=${encodeURIComponent(asset.name)}&type=${assetType}`
)
const subfolder = asset.user_metadata?.subfolder
const params = new URLSearchParams()
params.set('filename', asset.name)
params.set('type', assetType)
if (typeof subfolder === 'string' && subfolder) {
params.set('subfolder', subfolder)
}
return api.apiURL(`/view?${params}`)
}