fix: Hide delete button for input assets in OSS and fix cloud download (#6697)

## Summary
Fix delete button visibility for input assets in OSS environment and
resolve 404 error when downloading assets in cloud.

## Changes

### 1. Improved Delete Button Visibility Logic
- **Problem**: In OSS environment, input files are sourced from local
folders and cannot be deleted
- **Solution**: Added `shouldShowDeleteButton` computed property to
conditionally hide delete buttons
- **Impact**: 
  - Input tab + Cloud: Delete button shown 
  - Input tab + OSS: Delete button hidden 
  - Output tab (all environments): Delete button shown 

### 2. Fixed Cloud Download 404 Error
- **Problem**: Downloading files from imported tab in cloud returned 404
error for `/api/view` endpoint
- **Root Cause**: In cloud environment, files are stored in external
storage (e.g., GCS) and `/api/view` endpoint is not available
- **Solution**: 
  - Cloud: Use `preview_url` directly for downloads
  - OSS/localhost: Continue using `/api/view` endpoint as before
- Applied the same logic to both single and bulk download operations

## Test Plan
- [ ] Verify delete button is hidden in input tab on OSS environment
- [ ] Verify delete button is shown in input tab on cloud environment
- [ ] Verify file downloads work correctly in cloud for both input and
output tabs
- [ ] Verify file downloads work correctly in OSS for output tab

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Jin Yi
2025-11-14 15:57:43 +09:00
committed by GitHub
parent b347dd1734
commit c43cd287bb
2 changed files with 35 additions and 11 deletions

View File

@@ -25,11 +25,19 @@ export function useMediaAssetActions() {
if (!asset) return
try {
const assetType = asset.tags?.[0] || 'output'
const filename = asset.name
const downloadUrl = api.apiURL(
`/view?filename=${encodeURIComponent(filename)}&type=${assetType}`
)
let downloadUrl: string
// In cloud, use preview_url directly (from cloud storage)
// In OSS/localhost, use the /view endpoint
if (isCloud && asset.src) {
downloadUrl = asset.src
} else {
const assetType = asset.tags?.[0] || 'output'
downloadUrl = api.apiURL(
`/view?filename=${encodeURIComponent(filename)}&type=${assetType}`
)
}
downloadFile(downloadUrl, filename)
@@ -58,11 +66,19 @@ export function useMediaAssetActions() {
try {
assets.forEach((asset) => {
const assetType = asset.tags?.[0] || 'output'
const filename = asset.name
const downloadUrl = api.apiURL(
`/view?filename=${encodeURIComponent(filename)}&type=${assetType}`
)
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 {
const assetType = asset.tags?.[0] || 'output'
downloadUrl = api.apiURL(
`/view?filename=${encodeURIComponent(filename)}&type=${assetType}`
)
}
downloadFile(downloadUrl, filename)
})