-
Notifications
You must be signed in to change notification settings - Fork 8
Add download functionality to DAM folders #1230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
648162c
chore(api): add jszip library
jomunker 6c942a7
feat(FoldersController): add a folders controller with an endpoint wh…
jomunker f619788
chore(gitignore): add .idea folder to .gitignore
jomunker b33aaf3
feat(FoldersService): handle duplicate folder names
jomunker 9f20a98
fix(FoldersController): wrap filename property in double quotes to av…
jomunker e6ee99d
feat(FoldersService): throw error on empty subfolder zip
jomunker 7c6a104
refactor(FoldersController): rename zipBuffer to zipStream
jomunker 6f72a32
feat(DamContextMenu): add download link button
jomunker 92348e7
refactor(RowActionsItem): use more descriptive name for generic
jomunker 2a57696
refactor(cms-api): remove console log from folders.controller.ts
jomunker 38f3aed
refactor(cms-api): throw not found error instead of using fallback fo…
jomunker 017d90d
Merge branch 'main' into dam-download-folders
jomunker f0b672e
Merge branch 'main' into dam-download-folders
jomunker 770de6c
feat(folders.controller): add user scope check to createZip function
jomunker d2feb34
Merge branch 'main' into dam-download-folders
jomunker 7d94b72
refactor(RowActionsListItem): use any as generic in ForwardedRef
jomunker 2048789
Merge branch 'main' into dam-download-folders
thomasdax98 2494ca9
Replace ContentScopeService with accessControlService
thomasdax98 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ lang/ | |
.pnp.* | ||
junit.xml | ||
.env.local | ||
**/.idea | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Controller, ForbiddenException, Get, Inject, NotFoundException, Param, Res } from "@nestjs/common"; | ||
import { Response } from "express"; | ||
|
||
import { CurrentUserInterface } from "../../auth/current-user/current-user"; | ||
import { GetCurrentUser } from "../../auth/decorators/get-current-user.decorator"; | ||
import { ACCESS_CONTROL_SERVICE } from "../../user-permissions/user-permissions.constants"; | ||
import { AccessControlServiceInterface } from "../../user-permissions/user-permissions.types"; | ||
import { FoldersService } from "./folders.service"; | ||
|
||
@Controller("dam/folders") | ||
export class FoldersController { | ||
constructor( | ||
private readonly foldersService: FoldersService, | ||
@Inject(ACCESS_CONTROL_SERVICE) private accessControlService: AccessControlServiceInterface, | ||
) {} | ||
|
||
@Get("/:folderId/zip") | ||
async createZip(@Param("folderId") folderId: string, @Res() res: Response, @GetCurrentUser() user: CurrentUserInterface): Promise<void> { | ||
const folder = await this.foldersService.findOneById(folderId); | ||
jomunker marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (!folder) { | ||
throw new NotFoundException("Folder not found"); | ||
} | ||
|
||
if (folder.scope && !this.accessControlService.isAllowed(user, "dam", folder.scope)) { | ||
throw new ForbiddenException("The current user is not allowed to access this scope and download this folder."); | ||
} | ||
|
||
const zipStream = await this.foldersService.createZipStreamFromFolder(folderId); | ||
|
||
res.setHeader("Content-Disposition", `attachment; filename="${folder.name}.zip"`); | ||
res.setHeader("Content-Type", "application/zip"); | ||
zipStream.pipe(res); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.