mirror of
https://github.com/kyantech/Palmr.git
synced 2025-10-22 22:02:00 +00:00
Compare commits
80 Commits
v3.1.6-bet
...
cb4ed3f581
Author | SHA1 | Date | |
---|---|---|---|
|
cb4ed3f581 | ||
|
148676513d | ||
|
42a5b7a796 | ||
|
59fccd9a93 | ||
|
91a5a24c8b | ||
|
ff83364870 | ||
|
df31b325f6 | ||
|
cce9847242 | ||
|
39dc94b7f8 | ||
|
ab5ea156a3 | ||
|
4ff1eb28d9 | ||
|
17080e4465 | ||
|
c798c1bb1d | ||
|
0d7f9ca2b3 | ||
|
f78ecab2ed | ||
|
fcc877738f | ||
|
92722692f9 | ||
|
95ac0f195b | ||
|
d6c9b0d7d2 | ||
|
59f9e19ffb | ||
|
6086d2a0ac | ||
|
6b979a22fb | ||
|
e4bae380c9 | ||
|
3117904009 | ||
|
b078e94189 | ||
|
bd4212b44c | ||
|
b699bffb5b | ||
|
a755c5324f | ||
|
9072e7e866 | ||
|
d3d1057ba8 | ||
|
24eda85fdc | ||
|
d49d15ac9b | ||
|
e7b2062764 | ||
|
f21f972825 | ||
|
4f4e4a079e | ||
|
6fbb9aa9da | ||
|
0e610d002c | ||
|
abd8366e94 | ||
|
5d8c243125 | ||
|
d23af700da | ||
|
494161eb47 | ||
|
6a9728be4b | ||
|
5e889956c7 | ||
|
5afc6ea271 | ||
|
cc368377c2 | ||
|
51764be7d4 | ||
|
fe598b4a30 | ||
|
80286e57d9 | ||
|
9f36a48d15 | ||
|
94286e8452 | ||
|
0ce2d6a998 | ||
|
9e15fd7d2e | ||
|
736348ebe8 | ||
|
ddb981cba2 | ||
|
724452fb40 | ||
|
a2ac6a6268 | ||
|
aecda25b25 | ||
|
0f22b0bb23 | ||
|
edf6d70d69 | ||
|
a2ecd2e221 | ||
|
2f022cae5d | ||
|
bb3669f5b2 | ||
|
87fd8caf2c | ||
|
e8087a7c01 | ||
|
4075a7df29 | ||
|
c081b6f764 | ||
|
ecaa6d0321 | ||
|
e7ae7833ad | ||
|
22f34f6f81 | ||
|
29efe0a10e | ||
|
965c64b468 | ||
|
ce57cda672 | ||
|
a59857079e | ||
|
9ae2a0c628 | ||
|
f2c514cd82 | ||
|
6755230c53 | ||
|
f2a0e60f20 | ||
|
6cb21e95c4 | ||
|
868add68a5 | ||
|
307148d951 |
259
.github/copilot-instructions.md
vendored
Normal file
259
.github/copilot-instructions.md
vendored
Normal file
@@ -0,0 +1,259 @@
|
||||
# GitHub Copilot Instructions for Palmr
|
||||
|
||||
This file contains instructions for GitHub Copilot to help contributors work effectively with the Palmr codebase.
|
||||
|
||||
## Project Overview
|
||||
|
||||
Palmr is a flexible and open-source alternative to file transfer services like WeTransfer and SendGB. It's built with:
|
||||
|
||||
- **Backend**: Fastify (Node.js) with TypeScript, SQLite database, and filesystem/S3 storage
|
||||
- **Frontend**: Next.js 15 + React + TypeScript + Shadcn/ui
|
||||
- **Documentation**: Next.js + Fumadocs + MDX
|
||||
- **Package Manager**: pnpm (v10.6.0)
|
||||
- **Monorepo Structure**: Three main apps (web, server, docs) in the `apps/` directory
|
||||
|
||||
## Architecture and Structure
|
||||
|
||||
### Monorepo Layout
|
||||
|
||||
```
|
||||
apps/
|
||||
├── docs/ # Documentation site (Next.js + Fumadocs)
|
||||
├── server/ # Backend API (Fastify + TypeScript)
|
||||
└── web/ # Frontend application (Next.js 15)
|
||||
```
|
||||
|
||||
### Key Technologies
|
||||
|
||||
- **TypeScript**: Primary language for all applications
|
||||
- **Database**: Prisma ORM with SQLite (optional S3-compatible storage)
|
||||
- **Authentication**: Multiple OAuth providers (Google, GitHub, Discord, etc.)
|
||||
- **Internationalization**: Multi-language support with translation scripts
|
||||
- **Validation**: Husky pre-push hooks for linting and type checking
|
||||
|
||||
## Development Workflow
|
||||
|
||||
### Base Branch
|
||||
|
||||
Always create new branches from and submit PRs to the `next` branch, not `main`.
|
||||
|
||||
### Commit Convention
|
||||
|
||||
Use Conventional Commits format for all commits:
|
||||
|
||||
```
|
||||
<type>(<scope>): <description>
|
||||
|
||||
Types:
|
||||
- feat: New feature
|
||||
- fix: Bug fix
|
||||
- docs: Documentation changes
|
||||
- test: Adding or updating tests
|
||||
- refactor: Code refactoring
|
||||
- style: Code formatting
|
||||
- chore: Maintenance tasks
|
||||
```
|
||||
|
||||
Examples:
|
||||
|
||||
- `feat(web): add user authentication system`
|
||||
- `fix(api): resolve null pointer exception in user service`
|
||||
- `docs: update installation instructions in README`
|
||||
- `test(server): add unit tests for user validation`
|
||||
|
||||
### Code Quality Standards
|
||||
|
||||
1. **Linting**: All apps use ESLint. Run `pnpm lint` before committing
|
||||
2. **Formatting**: Use Prettier for code formatting. Run `pnpm format`
|
||||
3. **Type Checking**: Run `pnpm type-check` to validate TypeScript
|
||||
4. **Validation**: Run `pnpm validate` to run both linting and type checking
|
||||
5. **Pre-push Hook**: Automatically validates all apps before pushing
|
||||
|
||||
### Testing Changes
|
||||
|
||||
- Test incrementally during development
|
||||
- Run validation locally before pushing: `pnpm validate` in each app directory
|
||||
- Keep changes focused on a single issue or feature
|
||||
- Review your work before committing
|
||||
|
||||
## Application-Specific Guidelines
|
||||
|
||||
### Web App (`apps/web/`)
|
||||
|
||||
- Framework: Next.js 15 with App Router
|
||||
- Port: 3000 (development)
|
||||
- Scripts:
|
||||
- `pnpm dev`: Start development server
|
||||
- `pnpm build`: Build for production
|
||||
- `pnpm validate`: Run linting and type checking
|
||||
- Translations: Use Python scripts in `scripts/` directory
|
||||
- `pnpm translations:check`: Check translation status
|
||||
- `pnpm translations:sync`: Synchronize translations
|
||||
|
||||
### Server App (`apps/server/`)
|
||||
|
||||
- Framework: Fastify with TypeScript
|
||||
- Port: 3333 (default)
|
||||
- Scripts:
|
||||
- `pnpm dev`: Start development server with watch mode
|
||||
- `pnpm build`: Build TypeScript to JavaScript
|
||||
- `pnpm validate`: Run linting and type checking
|
||||
- `pnpm db:seed`: Seed database
|
||||
- Database: Prisma ORM with SQLite
|
||||
|
||||
### Docs App (`apps/docs/`)
|
||||
|
||||
- Framework: Next.js with Fumadocs
|
||||
- Port: 3001 (development)
|
||||
- Content: MDX files in `content/docs/`
|
||||
- Scripts:
|
||||
- `pnpm dev`: Start development server
|
||||
- `pnpm build`: Build documentation site
|
||||
- `pnpm validate`: Run linting and type checking
|
||||
|
||||
## Code Style and Best Practices
|
||||
|
||||
### General Guidelines
|
||||
|
||||
1. **Follow Style Guidelines**: Ensure code adheres to ESLint and Prettier configurations
|
||||
2. **TypeScript First**: Always use TypeScript, avoid `any` types when possible
|
||||
3. **Component Organization**: Keep components focused and single-purpose
|
||||
4. **Error Handling**: Implement proper error handling and logging
|
||||
5. **Comments**: Add comments only when necessary to explain complex logic
|
||||
6. **Imports**: Use absolute imports where configured, keep imports organized
|
||||
|
||||
### API Development (Server)
|
||||
|
||||
- Use Fastify's schema validation for all routes
|
||||
- Follow REST principles for endpoint design
|
||||
- Implement proper authentication and authorization
|
||||
- Handle errors gracefully with appropriate status codes
|
||||
- Document API endpoints in the docs app
|
||||
|
||||
### Frontend Development (Web)
|
||||
|
||||
- Use React Server Components where appropriate
|
||||
- Implement proper loading and error states
|
||||
- Follow accessibility best practices (WCAG guidelines)
|
||||
- Optimize performance (lazy loading, code splitting)
|
||||
- Use Shadcn/ui components for consistent UI
|
||||
|
||||
### Documentation
|
||||
|
||||
- Write clear, concise documentation
|
||||
- Include code examples where helpful
|
||||
- Update documentation when changing functionality
|
||||
- Use MDX features for interactive documentation
|
||||
- Follow the existing documentation structure
|
||||
|
||||
## Translation and Internationalization
|
||||
|
||||
- All user-facing strings should be translatable
|
||||
- Use the Next.js internationalization system
|
||||
- Translation files are in `apps/web/messages/`
|
||||
- Reference file: `en-US.json`
|
||||
- Run `pnpm translations:check` to verify translations
|
||||
- Mark untranslated strings with `[TO_TRANSLATE]` prefix
|
||||
|
||||
## Common Patterns
|
||||
|
||||
### Authentication Providers
|
||||
|
||||
- Provider configurations in `apps/server/src/modules/auth-providers/providers.config.ts`
|
||||
- Support for OAuth2 and OIDC protocols
|
||||
- Field mappings for user data normalization
|
||||
- Special handling for providers like GitHub that require additional API calls
|
||||
|
||||
### File Storage
|
||||
|
||||
- Default: Filesystem storage
|
||||
- Optional: S3-compatible object storage
|
||||
- File metadata stored in SQLite database
|
||||
|
||||
### Environment Variables
|
||||
|
||||
- Configure via `.env` files (not committed to repository)
|
||||
- Required variables documented in README or docs
|
||||
- Use environment-specific configurations
|
||||
|
||||
## Contributing Guidelines
|
||||
|
||||
### Pull Request Process
|
||||
|
||||
1. Fork the repository
|
||||
2. Create a branch from `next`: `git checkout -b feature/your-feature upstream/next`
|
||||
3. Make focused changes addressing a single issue/feature
|
||||
4. Write or update tests as needed
|
||||
5. Update documentation to reflect changes
|
||||
6. Ensure all validations pass: `pnpm validate` in each app
|
||||
7. Commit using Conventional Commits
|
||||
8. Push to your fork
|
||||
9. Create Pull Request targeting the `next` branch
|
||||
|
||||
### Code Review
|
||||
|
||||
- Be responsive to feedback
|
||||
- Keep discussions constructive and professional
|
||||
- Make requested changes promptly
|
||||
- Ask questions if requirements are unclear
|
||||
|
||||
### What to Avoid
|
||||
|
||||
- Don't mix unrelated changes in a single PR
|
||||
- Don't skip linting or type checking
|
||||
- Don't commit directly to `main` or `next` branches
|
||||
- Don't add unnecessary dependencies
|
||||
- Don't ignore existing code style and patterns
|
||||
- Don't remove or modify tests without good reason
|
||||
|
||||
## Helpful Commands
|
||||
|
||||
### Root Level
|
||||
|
||||
```bash
|
||||
pnpm install # Install all dependencies
|
||||
git config core.hooksPath .husky # Configure Git hooks
|
||||
```
|
||||
|
||||
### Per App (web/server/docs)
|
||||
|
||||
```bash
|
||||
pnpm dev # Start development server
|
||||
pnpm build # Build for production
|
||||
pnpm lint # Run ESLint
|
||||
pnpm lint:fix # Fix ESLint issues automatically
|
||||
pnpm format # Format code with Prettier
|
||||
pnpm format:check # Check code formatting
|
||||
pnpm type-check # Run TypeScript type checking
|
||||
pnpm validate # Run lint + type-check
|
||||
```
|
||||
|
||||
### Docker
|
||||
|
||||
```bash
|
||||
docker-compose up # Start all services
|
||||
docker-compose down # Stop all services
|
||||
```
|
||||
|
||||
## Resources
|
||||
|
||||
- **Documentation**: [https://palmr.kyantech.com.br](https://palmr.kyantech.com.br)
|
||||
- **Contributing Guide**: [CONTRIBUTING.md](../CONTRIBUTING.md)
|
||||
- **Issue Tracker**: GitHub Issues
|
||||
- **License**: Apache-2.0
|
||||
|
||||
## Getting Help
|
||||
|
||||
- Review existing documentation in `apps/docs/content/docs/`
|
||||
- Check contribution guide in `CONTRIBUTING.md`
|
||||
- Review existing code for patterns and examples
|
||||
- Ask questions in PR discussions or issues
|
||||
- Read error messages and logs carefully
|
||||
|
||||
## Important Notes
|
||||
|
||||
- **Beta Status**: This project is in beta; expect changes and improvements
|
||||
- **Focus on Quality**: Prioritize code quality and maintainability over speed
|
||||
- **Test Locally**: Always test your changes locally before submitting
|
||||
- **Documentation Matters**: Keep documentation synchronized with code
|
||||
- **Community First**: Be respectful, patient, and constructive with all contributors
|
3
.gitignore
vendored
3
.gitignore
vendored
@@ -33,4 +33,5 @@ apps/server/dist/*
|
||||
.steering
|
||||
data/
|
||||
|
||||
node_modules/
|
||||
node_modules/
|
||||
screenshots/
|
@@ -1,4 +1,4 @@
|
||||
FROM node:20-alpine AS base
|
||||
FROM node:24-alpine AS base
|
||||
|
||||
# Install system dependencies
|
||||
RUN apk add --no-cache \
|
||||
|
212
LICENSE
212
LICENSE
@@ -1,40 +1,190 @@
|
||||
Kyantech-Permissive License (Based on BSD 2-Clause)
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
Copyright (c) 2025, Daniel Luiz Alves (danielalves96) - Kyantech Solutions
|
||||
All rights reserved.
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted for any purpose — private, commercial,
|
||||
educational, governmental — **fully free and unrestricted**, provided
|
||||
that the following conditions are met:
|
||||
1. Definitions.
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions, and the following disclaimer.
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions, and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
3. **If this software (or derivative works) is used in any public-facing
|
||||
interface** — such as websites, apps, dashboards, admin panels, or
|
||||
similar — a **simple credit** must appear in the footer or similar
|
||||
location. The credit text should read:
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
> “Powered by Kyantech Solutions · https://kyantech.com.br”
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
This credit must be reasonably visible but **must not interfere** with
|
||||
your UI, branding, or user experience. You may style it to match your
|
||||
own design and choose its size, placement, or color.
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
---
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Copyright 2025 Daniel Luiz Alves (danielalves96) - Kyantech Solutions, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
296
README.md
296
README.md
@@ -1,142 +1,154 @@
|
||||
# 🌴 Palmr. - Open-Source File Transfer
|
||||
|
||||
<p align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749825361/Group_47_1_bcx8gw.png" alt="Palmr Banner" style="width: 100%;"/>
|
||||
</p>
|
||||
|
||||
**Palmr.** is a **flexible** and **open-source** alternative to file transfer services like **WeTransfer**, **SendGB**, **Send Anywhere**, and **Files.fm**.
|
||||
|
||||
|
||||
🔗 **For detailed documentation visit:** [Palmr. - Documentation](https://palmr.kyantech.com.br)
|
||||
|
||||
## 📌 Why Choose Palmr.?
|
||||
|
||||
- **Self-hosted** – Deploy on your own server or VPS.
|
||||
- **Full control** – No third-party dependencies, ensuring privacy and security.
|
||||
- **No artificial limits** – Share files without hidden restrictions or fees.
|
||||
- **Simple deployment** – SQLite database and filesystem storage for easy setup.
|
||||
- **Scalable storage** – Optional S3-compatible object storage for enterprise needs.
|
||||
|
||||
## 🚀 Technologies Used
|
||||
|
||||
### **Palmr.** is built with a focus on **performance**, **scalability**, and **security**.
|
||||
|
||||
<div align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1745548231/Palmr./Captura_de_Tela_2025-04-24_a%CC%80s_23.24.26_kr4hsl.png" style="width: 100%; border-radius: 15px;" />
|
||||
</div>
|
||||
|
||||
|
||||
### **Backend & API**
|
||||
- **Fastify (Node.js)** – High-performance API framework with built-in schema validation.
|
||||
- **SQLite** – Lightweight, reliable database with zero-configuration setup.
|
||||
- **Filesystem Storage** – Direct file storage with optional S3-compatible object storage.
|
||||
|
||||
### **Frontend**
|
||||
- **NextJS 15 + TypeScript + Shadcn/ui** – Modern and fast web interface.
|
||||
|
||||
|
||||
## 🛠️ How It Works
|
||||
|
||||
1. **Web Interface** → Built with Next, React and TypeScript for a seamless user experience.
|
||||
2. **Backend API** → Fastify handles requests and manages file operations.
|
||||
3. **Database** → SQLite stores metadata and transactional data with zero configuration.
|
||||
4. **Storage** → Filesystem storage ensures reliable file storage with optional S3-compatible object storage for scalability.
|
||||
|
||||
## 📸 Screenshots
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824929/Login_veq6e7.png" alt="Login Page" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Login Page</strong>
|
||||
</td>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824929/Home_lzvfzu.png" alt="Home Page" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Home Page</strong>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824928/Dashboard_uycmxb.png" alt="Dashboard" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Dashboard</strong>
|
||||
</td>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824929/Profile_wvnlzw.png" alt="Profile Page" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Profile Page</strong>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824928/Files_List_ztwr1e.png" alt="Files List View" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Files List View</strong>
|
||||
</td>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824928/Files_Cards_pwsh5e.png" alt="Files Card View" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Files Card View</strong>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824927/Shares_cgplgw.png" alt="Shares Management" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Shares Management</strong>
|
||||
</td>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824928/Reive_Files_uhkeyc.png" alt="Receive Files" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Receive Files</strong>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824927/Default_Reverse_xedmhw.png" alt="Reverse Share" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Reverse Share</strong>
|
||||
</td>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824928/Settings_oampxr.png" alt="Settings Panel" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Settings Panel</strong>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824928/User_Management_xjbfhn.png" alt="User Management" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>User Management</strong>
|
||||
</td>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824928/Forgot_Password_jcz9ad.png" alt="Forgot Password" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Forgot Password</strong>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824928/WeTransfer_Reverse_u0g7eb.png" alt="Forgot Password" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Reverse Share (WeTransfer Style)</strong>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
## 👨💻 Core Maintainers
|
||||
|
||||
| [**Daniel Luiz Alves**](https://github.com/danielalves96) |
|
||||
|------------------|
|
||||
| <img src="https://github.com/danielalves96.png" width="150px" alt="Daniel Luiz Alves" /> |
|
||||
|
||||
</br>
|
||||
|
||||
## 🤝 Supporters
|
||||
|
||||
[<img src="https://i.ibb.co/nMN40STL/Repoflow.png" width="200px" alt="Daniel Luiz Alves" />](https://www.repoflow.io/)
|
||||
|
||||
## ⭐ Star History
|
||||
|
||||
<a href="https://www.star-history.com/#kyantech/Palmr&Date">
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=kyantech/Palmr&type=Date&theme=dark" />
|
||||
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=kyantech/Palmr&type=Date" />
|
||||
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=kyantech/Palmr&type=Date" />
|
||||
</picture>
|
||||
</a>
|
||||
|
||||
## 🛠️ Contributing
|
||||
|
||||
For contribution guidelines, please refer to the [CONTRIBUTING.md](CONTRIBUTING.md) file.
|
||||
|
||||
# 🌴 Palmr. - Open-Source File Transfer
|
||||
|
||||
<p align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749825361/Group_47_1_bcx8gw.png" alt="Palmr Banner" style="width: 100%;"/>
|
||||
</p>
|
||||
|
||||
**Palmr.** is a **flexible** and **open-source** alternative to file transfer services like **WeTransfer**, **SendGB**, **Send Anywhere**, and **Files.fm**.
|
||||
|
||||
<div align="center">
|
||||
<div style="background: linear-gradient(135deg, #ff4757, #ff3838); padding: 20px; border-radius: 12px; margin: 20px 0; box-shadow: 0 4px 15px rgba(255, 71, 87, 0.3); border: 2px solid #ff3838;">
|
||||
<h3 style="color: white; margin: 0 0 10px 0; font-size: 18px; font-weight: bold;">
|
||||
⚠️ BETA VERSION
|
||||
</h3>
|
||||
<p style="color: white; margin: 0; font-size: 14px; opacity: 0.95;">
|
||||
<strong>This project is currently in beta phase.</strong><br>
|
||||
Not recommended for production environments.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
🔗 **For detailed documentation visit:** [Palmr. - Documentation](https://palmr.kyantech.com.br)
|
||||
|
||||
## 📌 Why Choose Palmr.?
|
||||
|
||||
- **Self-hosted** – Deploy on your own server or VPS.
|
||||
- **Full control** – No third-party dependencies, ensuring privacy and security.
|
||||
- **No artificial limits** – Share files without hidden restrictions or fees.
|
||||
- **Folder organization** – Create folders to organize and share files.
|
||||
- **Simple deployment** – SQLite database and filesystem storage for easy setup.
|
||||
- **Scalable storage** – Optional S3-compatible object storage for enterprise needs.
|
||||
|
||||
## 🚀 Technologies Used
|
||||
|
||||
### **Palmr.** is built with a focus on **performance**, **scalability**, and **security**.
|
||||
|
||||
<div align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1745548231/Palmr./Captura_de_Tela_2025-04-24_a%CC%80s_23.24.26_kr4hsl.png" style="width: 100%; border-radius: 15px;" />
|
||||
</div>
|
||||
|
||||
|
||||
### **Backend & API**
|
||||
- **Fastify (Node.js)** – High-performance API framework with built-in schema validation.
|
||||
- **SQLite** – Lightweight, reliable database with zero-configuration setup.
|
||||
- **Filesystem Storage** – Direct file storage with optional S3-compatible object storage.
|
||||
|
||||
### **Frontend**
|
||||
- **NextJS 15 + TypeScript + Shadcn/ui** – Modern and fast web interface.
|
||||
|
||||
|
||||
## 🛠️ How It Works
|
||||
|
||||
1. **Web Interface** → Built with Next, React and TypeScript for a seamless user experience.
|
||||
2. **Backend API** → Fastify handles requests and manages file operations.
|
||||
3. **Database** → SQLite stores metadata and transactional data with zero configuration.
|
||||
4. **Storage** → Filesystem storage ensures reliable file storage with optional S3-compatible object storage for scalability.
|
||||
|
||||
## 📸 Screenshots
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824929/Login_veq6e7.png" alt="Login Page" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Login Page</strong>
|
||||
</td>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824929/Home_lzvfzu.png" alt="Home Page" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Home Page</strong>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824928/Dashboard_uycmxb.png" alt="Dashboard" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Dashboard</strong>
|
||||
</td>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824929/Profile_wvnlzw.png" alt="Profile Page" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Profile Page</strong>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824928/Files_List_ztwr1e.png" alt="Files List View" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Files List View</strong>
|
||||
</td>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824928/Files_Cards_pwsh5e.png" alt="Files Card View" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Files Card View</strong>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824927/Shares_cgplgw.png" alt="Shares Management" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Shares Management</strong>
|
||||
</td>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824928/Reive_Files_uhkeyc.png" alt="Receive Files" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Receive Files</strong>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824927/Default_Reverse_xedmhw.png" alt="Reverse Share" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Reverse Share</strong>
|
||||
</td>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824928/Settings_oampxr.png" alt="Settings Panel" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Settings Panel</strong>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824928/User_Management_xjbfhn.png" alt="User Management" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>User Management</strong>
|
||||
</td>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824928/Forgot_Password_jcz9ad.png" alt="Forgot Password" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Forgot Password</strong>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824928/WeTransfer_Reverse_u0g7eb.png" alt="Forgot Password" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Reverse Share (WeTransfer Style)</strong>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
## 👨💻 Core Maintainers
|
||||
|
||||
| [**Daniel Luiz Alves**](https://github.com/danielalves96) |
|
||||
|------------------|
|
||||
| <img src="https://github.com/danielalves96.png" width="150px" alt="Daniel Luiz Alves" /> |
|
||||
|
||||
</br>
|
||||
|
||||
## 🤝 Supporters
|
||||
|
||||
[<img src="https://i.ibb.co/nMN40STL/Repoflow.png" width="200px" alt="Daniel Luiz Alves" />](https://www.repoflow.io/)
|
||||
|
||||
## ⭐ Star History
|
||||
|
||||
<a href="https://www.star-history.com/#kyantech/Palmr&Date">
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=kyantech/Palmr&type=Date&theme=dark" />
|
||||
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=kyantech/Palmr&type=Date" />
|
||||
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=kyantech/Palmr&type=Date" />
|
||||
</picture>
|
||||
</a>
|
||||
|
||||
## 🛠️ Contributing
|
||||
|
||||
For contribution guidelines, please refer to the [CONTRIBUTING.md](CONTRIBUTING.md) file.
|
||||
|
||||
|
@@ -105,6 +105,12 @@ The Palmr. API provides comprehensive access to all platform features:
|
||||
- **File management** - Rename, delete, and organize files
|
||||
- **Metadata access** - Retrieve file information and properties
|
||||
|
||||
### Folder operations
|
||||
|
||||
- **Create folders** - Build folder structures for organization
|
||||
- **Folder management** - Rename, move, delete folders
|
||||
- **Folder sharing** - Share folders with same controls as files
|
||||
|
||||
### Share management
|
||||
|
||||
- **Create shares** - Generate public links for file sharing
|
@@ -51,7 +51,7 @@ If you need to protect sensitive files at rest, you can enable encryption by set
|
||||
|
||||
For optimal performance with encryption enabled, ensure your hardware supports AES-NI acceleration (check with `cat /proc/cpuinfo | grep aes` on Linux).
|
||||
|
||||
As an alternative, consider using S3-compatible object storage (e.g., AWS S3 or MinIO), which can offload file storage from the local filesystem and potentially reduce local CPU overhead for encryption/decryption. See [S3 Providers](/docs/3.1-beta/s3-providers) for setup instructions.
|
||||
As an alternative, consider using S3-compatible object storage (e.g., AWS S3 or MinIO), which can offload file storage from the local filesystem and potentially reduce local CPU overhead for encryption/decryption. See [S3 Providers](/docs/3.2-beta/s3-providers) for setup instructions.
|
||||
|
||||
### Fastify + Zod + TypeScript
|
||||
|
||||
@@ -127,7 +127,7 @@ Palmr. is designed to be flexible in how you handle file storage:
|
||||
|
||||
**Optional S3-compatible storage:**
|
||||
|
||||
- Enable S3 storage by setting `ENABLE_S3=true`, look at [S3 Providers](/docs/3.1-beta/s3-providers) for more information.
|
||||
- Enable S3 storage by setting `ENABLE_S3=true`, look at [S3 Providers](/docs/3.2-beta/s3-providers) for more information.
|
||||
- Compatible with AWS S3, MinIO, and other S3-compatible services
|
||||
- Ideal for cloud deployments and distributed setups
|
||||
- Provides additional scalability and redundancy options
|
374
apps/docs/content/docs/3.2-beta/cleanup-orphan-files.mdx
Normal file
374
apps/docs/content/docs/3.2-beta/cleanup-orphan-files.mdx
Normal file
@@ -0,0 +1,374 @@
|
||||
---
|
||||
title: Cleanup Orphan Files
|
||||
icon: Trash2
|
||||
---
|
||||
|
||||
This guide provides detailed instructions on how to identify and remove orphan file records from your Palmr database. Orphan files are database entries that reference files that no longer exist in the storage system, typically resulting from failed uploads or interrupted transfers.
|
||||
|
||||
## When and why to use this tool
|
||||
|
||||
The orphan file cleanup script is designed to maintain database integrity by removing stale file records. Consider using this tool if:
|
||||
|
||||
- Users are experiencing "File not found" errors when attempting to download files that appear in the UI
|
||||
- You've identified failed uploads that left incomplete database records
|
||||
- You're performing routine database maintenance
|
||||
- You've migrated storage systems and need to verify file consistency
|
||||
- You need to free up quota space occupied by phantom file records
|
||||
|
||||
> **Note:** This script only removes **database records** for files that don't exist in storage. It does not delete physical files. Files that exist in storage will remain untouched.
|
||||
|
||||
## How the cleanup works
|
||||
|
||||
Palmr provides a maintenance script that scans all file records in the database and verifies their existence in the storage system (either filesystem or S3). The script operates in two modes:
|
||||
|
||||
- **Dry-run mode (default):** Identifies orphan files and displays what would be deleted without making any changes
|
||||
- **Confirmation mode:** Actually removes the orphan database records after explicit confirmation
|
||||
|
||||
The script maintains safety by:
|
||||
- Checking file existence before marking as orphan
|
||||
- Providing detailed statistics and file listings
|
||||
- Requiring explicit `--confirm` flag to delete records
|
||||
- Working with both filesystem and S3 storage providers
|
||||
- Preserving all files that exist in storage
|
||||
|
||||
## Understanding orphan files
|
||||
|
||||
### What are orphan files?
|
||||
|
||||
Orphan files occur when:
|
||||
|
||||
1. **Failed chunked uploads:** A large file upload starts, creates a database record, but the upload fails before completion
|
||||
2. **Interrupted transfers:** Network issues or server restarts interrupt file transfers mid-process
|
||||
3. **Manual deletions:** Files are manually deleted from storage without removing the database record
|
||||
4. **Storage migrations:** Files are moved or lost during storage system changes
|
||||
|
||||
### Why they cause problems
|
||||
|
||||
When orphan records exist in the database:
|
||||
- Users see files in the UI that cannot be downloaded
|
||||
- Download attempts result in "ENOENT: no such file or directory" errors
|
||||
- Storage quota calculations become inaccurate
|
||||
- The system returns 500 errors instead of proper 404 responses (in older versions)
|
||||
|
||||
### Renamed files with suffixes
|
||||
|
||||
Files with duplicate names are automatically renamed with suffixes (e.g., `file (1).png`, `file (2).png`). Sometimes the upload fails after the database record is created but before the physical file is saved, creating an orphan record with a suffix.
|
||||
|
||||
**Example:**
|
||||
```
|
||||
Database record: photo (1).png → objectName: user123/1758805195682-Rjn9at692HdR.png
|
||||
Physical file: Does not exist ❌
|
||||
```
|
||||
|
||||
## Step-by-step instructions
|
||||
|
||||
### 1. Access the server environment
|
||||
|
||||
**For Docker installations:**
|
||||
|
||||
```bash
|
||||
docker exec -it <container_name> /bin/sh
|
||||
cd /app/palmr-app
|
||||
```
|
||||
|
||||
**For bare-metal installations:**
|
||||
|
||||
```bash
|
||||
cd /path/to/palmr/apps/server
|
||||
```
|
||||
|
||||
### 2. Run the cleanup script in dry-run mode
|
||||
|
||||
First, run the script without the `--confirm` flag to see what would be deleted:
|
||||
|
||||
```bash
|
||||
pnpm cleanup:orphan-files
|
||||
```
|
||||
|
||||
This will:
|
||||
- Scan all file records in the database
|
||||
- Check if each file exists in storage
|
||||
- Display a summary of orphan files
|
||||
- Show what would be deleted (without actually deleting)
|
||||
|
||||
### 3. Review the output
|
||||
|
||||
The script will provide detailed information about orphan files:
|
||||
|
||||
```text
|
||||
Starting orphan file cleanup...
|
||||
Storage mode: Filesystem
|
||||
Found 7 files in database
|
||||
❌ Orphan: photo(1).png (cmddjchw80000gmiimqnxga2g/1758805195682-Rjn9at692HdR.png)
|
||||
❌ Orphan: document.pdf (cmddjchw80000gmiimqnxga2g/1758803757558-JQxlvF816UVo.pdf)
|
||||
|
||||
📊 Summary:
|
||||
Total files in DB: 7
|
||||
✅ Files with storage: 5
|
||||
❌ Orphan files: 2
|
||||
|
||||
🗑️ Orphan files to be deleted:
|
||||
- photo(1).png (0.76 MB) - cmddjchw80000gmiimqnxga2g/1758805195682-Rjn9at692HdR.png
|
||||
- document.pdf (2.45 MB) - cmddjchw80000gmiimqnxga2g/1758803757558-JQxlvF816UVo.pdf
|
||||
|
||||
⚠️ Dry run mode. To actually delete orphan records, run with --confirm flag:
|
||||
pnpm cleanup:orphan-files:confirm
|
||||
```
|
||||
|
||||
### 4. Confirm and execute the cleanup
|
||||
|
||||
If you're satisfied with the results and want to proceed with the deletion:
|
||||
|
||||
```bash
|
||||
pnpm cleanup:orphan-files:confirm
|
||||
```
|
||||
|
||||
This will remove the orphan database records and display a confirmation:
|
||||
|
||||
```text
|
||||
🗑️ Deleting orphan file records...
|
||||
✓ Deleted: photo(1).png
|
||||
✓ Deleted: document.pdf
|
||||
|
||||
✅ Cleanup complete!
|
||||
Deleted 2 orphan file records
|
||||
```
|
||||
|
||||
## Example session
|
||||
|
||||
Below is a complete example of running the cleanup script:
|
||||
|
||||
```bash
|
||||
$ pnpm cleanup:orphan-files
|
||||
|
||||
> palmr-api@3.2.3-beta cleanup:orphan-files
|
||||
> tsx src/scripts/cleanup-orphan-files.ts
|
||||
|
||||
Starting orphan file cleanup...
|
||||
Storage mode: Filesystem
|
||||
Found 15 files in database
|
||||
❌ Orphan: video.mp4 (user123/1758803869037-1WhtnrQioeFQ.mp4)
|
||||
❌ Orphan: image(1).png (user123/1758805195682-Rjn9at692HdR.png)
|
||||
❌ Orphan: image(2).png (user123/1758803757558-JQxlvF816UVo.png)
|
||||
|
||||
📊 Summary:
|
||||
Total files in DB: 15
|
||||
✅ Files with storage: 12
|
||||
❌ Orphan files: 3
|
||||
|
||||
🗑️ Orphan files to be deleted:
|
||||
- video.mp4 (97.09 MB) - user123/1758803869037-1WhtnrQioeFQ.mp4
|
||||
- image(1).png (0.01 MB) - user123/1758805195682-Rjn9at692HdR.png
|
||||
- image(2).png (0.76 MB) - user123/1758803757558-JQxlvF816UVo.png
|
||||
|
||||
⚠️ Dry run mode. To actually delete orphan records, run with --confirm flag:
|
||||
pnpm cleanup:orphan-files:confirm
|
||||
|
||||
$ pnpm cleanup:orphan-files:confirm
|
||||
|
||||
> palmr-api@3.2.3-beta cleanup:orphan-files:confirm
|
||||
> tsx src/scripts/cleanup-orphan-files.ts --confirm
|
||||
|
||||
Starting orphan file cleanup...
|
||||
Storage mode: Filesystem
|
||||
Found 15 files in database
|
||||
❌ Orphan: video.mp4 (user123/1758803869037-1WhtnrQioeFQ.mp4)
|
||||
❌ Orphan: image(1).png (user123/1758805195682-Rjn9at692HdR.png)
|
||||
❌ Orphan: image(2).png (user123/1758803757558-JQxlvF816UVo.png)
|
||||
|
||||
📊 Summary:
|
||||
Total files in DB: 15
|
||||
✅ Files with storage: 12
|
||||
❌ Orphan files: 3
|
||||
|
||||
🗑️ Orphan files to be deleted:
|
||||
- video.mp4 (97.09 MB) - user123/1758803869037-1WhtnrQioeFQ.mp4
|
||||
- image(1).png (0.01 MB) - user123/1758805195682-Rjn9at692HdR.png
|
||||
- image(2).png (0.76 MB) - user123/1758803757558-JQxlvF816UVo.png
|
||||
|
||||
🗑️ Deleting orphan file records...
|
||||
✓ Deleted: video.mp4
|
||||
✓ Deleted: image(1).png
|
||||
✓ Deleted: image(2).png
|
||||
|
||||
✅ Cleanup complete!
|
||||
Deleted 3 orphan file records
|
||||
|
||||
Script completed successfully
|
||||
```
|
||||
|
||||
## Troubleshooting common issues
|
||||
|
||||
### No orphan files found
|
||||
|
||||
```text
|
||||
📊 Summary:
|
||||
Total files in DB: 10
|
||||
✅ Files with storage: 10
|
||||
❌ Orphan files: 0
|
||||
|
||||
✨ No orphan files found!
|
||||
```
|
||||
|
||||
**This is good!** It means your database is in sync with your storage system.
|
||||
|
||||
### Script cannot connect to database
|
||||
|
||||
If you see database connection errors:
|
||||
|
||||
1. Verify the database file exists:
|
||||
```bash
|
||||
ls -la prisma/palmr.db
|
||||
```
|
||||
|
||||
2. Check database permissions:
|
||||
```bash
|
||||
chmod 644 prisma/palmr.db
|
||||
```
|
||||
|
||||
3. Ensure you're in the correct directory:
|
||||
```bash
|
||||
pwd # Should show .../palmr/apps/server
|
||||
```
|
||||
|
||||
### Storage provider errors
|
||||
|
||||
For **S3 storage:**
|
||||
- Verify your S3 credentials are configured correctly
|
||||
- Check that the bucket is accessible
|
||||
- Ensure network connectivity to S3
|
||||
|
||||
For **Filesystem storage:**
|
||||
- Verify the uploads directory exists and is readable
|
||||
- Check file system permissions
|
||||
- Ensure sufficient disk space
|
||||
|
||||
### Script fails to delete records
|
||||
|
||||
If deletion fails for specific files:
|
||||
- Check database locks (close other connections)
|
||||
- Verify you have write permissions to the database
|
||||
- Review the error message for specific details
|
||||
|
||||
## Understanding the output
|
||||
|
||||
### File statistics
|
||||
|
||||
The script provides several key metrics:
|
||||
|
||||
- **Total files in DB:** All file records in your database
|
||||
- **Files with storage:** Records where the physical file exists
|
||||
- **Orphan files:** Records where the physical file is missing
|
||||
|
||||
### File information
|
||||
|
||||
For each orphan file, you'll see:
|
||||
|
||||
- **Name:** Display name in the UI
|
||||
- **Size:** File size as recorded in the database
|
||||
- **Object name:** Internal storage path
|
||||
|
||||
Example: `photo(1).png (0.76 MB) - user123/1758805195682-Rjn9at692HdR.png`
|
||||
|
||||
## Prevention and best practices
|
||||
|
||||
### Prevent orphan files from occurring
|
||||
|
||||
1. **Monitor upload failures:** Check server logs for upload errors
|
||||
2. **Stable network:** Ensure reliable network connectivity for large uploads
|
||||
3. **Adequate resources:** Provide sufficient disk space and memory
|
||||
4. **Regular maintenance:** Run this script periodically as part of maintenance
|
||||
|
||||
### When to run cleanup
|
||||
|
||||
Consider running the cleanup script:
|
||||
|
||||
- **Monthly:** As part of routine database maintenance
|
||||
- **After incidents:** Following server crashes or storage issues
|
||||
- **Before migrations:** Before moving to new storage systems
|
||||
- **When users report errors:** If download failures are reported
|
||||
|
||||
### Safe cleanup practices
|
||||
|
||||
1. **Always run dry-run first:** Review what will be deleted before confirming
|
||||
2. **Backup your database:** Create a backup before running with `--confirm`
|
||||
3. **Check during low usage:** Run during off-peak hours to minimize disruption
|
||||
4. **Document the cleanup:** Keep records of when and why cleanup was performed
|
||||
5. **Verify after cleanup:** Check that file counts match expectations
|
||||
|
||||
## Technical details
|
||||
|
||||
### How files are stored
|
||||
|
||||
When files are uploaded to Palmr:
|
||||
|
||||
1. Frontend generates a safe object name using random identifiers
|
||||
2. Backend creates the final `objectName` as: `${userId}/${timestamp}-${randomId}.${extension}`
|
||||
3. If a duplicate name exists, the **display name** gets a suffix, but `objectName` remains unique
|
||||
4. Physical file is stored using `objectName`, display name is stored separately in database
|
||||
|
||||
### Storage providers
|
||||
|
||||
The script works with both storage providers:
|
||||
|
||||
- **FilesystemStorageProvider:** Uses `fs.promises.access()` to check file existence
|
||||
- **S3StorageProvider:** Uses `HeadObjectCommand` to verify objects in S3 bucket
|
||||
|
||||
### Database schema
|
||||
|
||||
Files table structure:
|
||||
```typescript
|
||||
{
|
||||
name: string // Display name (can have suffixes like "file (1).png")
|
||||
objectName: string // Physical storage path (always unique)
|
||||
size: bigint // File size in bytes
|
||||
extension: string // File extension
|
||||
userId: string // Owner of the file
|
||||
folderId: string? // Parent folder (null for root)
|
||||
}
|
||||
```
|
||||
|
||||
## Related improvements
|
||||
|
||||
### Download validation (v3.2.3-beta+)
|
||||
|
||||
Starting from version 3.2.3-beta, Palmr includes enhanced download validation:
|
||||
|
||||
- Files are checked for existence **before** attempting download
|
||||
- Returns proper 404 error if file is missing (instead of 500)
|
||||
- Provides helpful error message to users
|
||||
|
||||
This prevents errors when trying to download orphan files that haven't been cleaned up yet.
|
||||
|
||||
## Security considerations
|
||||
|
||||
- **Read-only by default:** Dry-run mode is safe and doesn't modify data
|
||||
- **Explicit confirmation:** Requires `--confirm` flag to delete records
|
||||
- **No file deletion:** Only removes database records, never deletes physical files
|
||||
- **Audit trail:** All actions are logged to console
|
||||
- **Permission-based:** Only users with server access can run the script
|
||||
|
||||
> **Important:** This script does not delete physical files from storage. It only removes database records for files that don't exist. This is intentional to prevent accidental data loss.
|
||||
|
||||
## FAQ
|
||||
|
||||
**Q: Will this delete my files?**
|
||||
A: No. The script only removes database records for files that are already missing from storage. Physical files are never deleted.
|
||||
|
||||
**Q: Can I undo the cleanup?**
|
||||
A: No. Once orphan records are deleted, they cannot be recovered. Always run dry-run mode first and backup your database.
|
||||
|
||||
**Q: Why do orphan files have suffixes like (1), (2)?**
|
||||
A: When duplicate files are uploaded, Palmr renames them with suffixes. If the upload fails after creating the database record, an orphan with a suffix remains.
|
||||
|
||||
**Q: How often should I run this script?**
|
||||
A: Monthly maintenance is usually sufficient. Run more frequently if you experience many upload failures.
|
||||
|
||||
**Q: Does this work with S3 storage?**
|
||||
A: Yes! The script automatically detects your storage provider (filesystem or S3) and works with both.
|
||||
|
||||
**Q: What if I have thousands of orphan files?**
|
||||
A: The script handles large numbers efficiently. Consider running during off-peak hours for very large cleanups.
|
||||
|
||||
**Q: Can this fix "File not found" errors?**
|
||||
A: Yes, if the errors are caused by orphan database records. The script removes those records, preventing future errors.
|
391
apps/docs/content/docs/3.2-beta/download-memory-management.mdx
Normal file
391
apps/docs/content/docs/3.2-beta/download-memory-management.mdx
Normal file
@@ -0,0 +1,391 @@
|
||||
---
|
||||
title: Memory Management
|
||||
icon: Download
|
||||
---
|
||||
|
||||
import { Callout } from "fumadocs-ui/components/callout";
|
||||
import { Tab, Tabs } from "fumadocs-ui/components/tabs";
|
||||
|
||||
Palmr implements an intelligent memory management system that prevents crashes during large file downloads (3GB+ by default), maintaining unlimited download capacity through adaptive resource control and an automatic queue system.
|
||||
|
||||
## How It Works
|
||||
|
||||
### Automatic Resource Detection
|
||||
|
||||
The system automatically detects available container/system memory and configures appropriate limits based on available infrastructure:
|
||||
|
||||
```typescript
|
||||
const totalMemoryGB = require("os").totalmem() / 1024 ** 3;
|
||||
```
|
||||
|
||||
### System Configuration
|
||||
|
||||
The system supports two configuration approaches that you can choose based on your needs:
|
||||
|
||||
<Tabs items={["Manual Configuration", "Auto-scaling (Default)"]}>
|
||||
<Tab value="Manual Configuration">
|
||||
Manually configure all parameters for total control over the system:
|
||||
|
||||
```bash
|
||||
# Custom configuration (overrides auto-scaling)
|
||||
DOWNLOAD_MAX_CONCURRENT=8 # Maximum simultaneous downloads
|
||||
DOWNLOAD_MEMORY_THRESHOLD_MB=1536 # Memory threshold in MB
|
||||
DOWNLOAD_QUEUE_SIZE=40 # Maximum queue size
|
||||
DOWNLOAD_AUTO_SCALE=false # Disable auto-scaling
|
||||
```
|
||||
|
||||
<Callout>
|
||||
Manual configuration offers total control and predictability for specific environments where you know exactly the available resources.
|
||||
</Callout>
|
||||
|
||||
</Tab>
|
||||
<Tab value="Auto-scaling (Default)">
|
||||
Automatic configuration based on detected system memory:
|
||||
|
||||
| Available Memory | Concurrent Downloads | Memory Threshold | Queue Size | Recommended Use |
|
||||
|------------------|----------------------|-------------------|------------|--------------------|
|
||||
| ≤ 2GB | 1 | 256MB | 5 | Development |
|
||||
| 2GB - 4GB | 2 | 512MB | 10 | Small Environment |
|
||||
| 4GB - 8GB | 3 | 1GB | 15 | Standard Production|
|
||||
| 8GB - 16GB | 5 | 2GB | 25 | High Performance |
|
||||
| > 16GB | 10 | 4GB | 50 | Enterprise |
|
||||
|
||||
<Callout>
|
||||
Auto-scaling automatically adapts to different environments without manual configuration, perfect for flexible deployment.
|
||||
</Callout>
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
<Callout type="info">If environment variables are configured, they take **priority** over auto-scaling.</Callout>
|
||||
|
||||
## Download Queue System
|
||||
|
||||
### How It Works
|
||||
|
||||
The memory management system only activates for files larger than the configured minimum size (3GB by default). Smaller files bypass the queue system entirely and download immediately without memory management.
|
||||
|
||||
When a user requests a download for a large file but all slots are occupied, the system automatically queues the download instead of returning a 429 error. The queue processes downloads in FIFO order (first in, first out).
|
||||
|
||||
### Practical Example
|
||||
|
||||
Consider a system with 8GB RAM (5 concurrent downloads, queue of 25, 3GB minimum) where users want to download files of various sizes:
|
||||
|
||||
```bash
|
||||
# Small files (< 3GB): Bypass queue entirely
|
||||
[DOWNLOAD MANAGER] File document.pdf (0.05GB) below threshold (3.0GB), bypassing queue
|
||||
|
||||
# Large files 1-5: Start immediately
|
||||
[DOWNLOAD MANAGER] Immediate start: 1734567890-abc123def
|
||||
[DOWNLOAD MANAGER] Starting video1.mp4 (5.2GB)
|
||||
|
||||
# Large files 6-10: Automatically queued
|
||||
[DOWNLOAD MANAGER] Queued: 1734567891-def456ghi (Position: 1/25)
|
||||
[DOWNLOAD MANAGER] Queued file: video2.mp4 (8.1GB)
|
||||
|
||||
# When download 1 finishes: download 6 starts automatically
|
||||
[DOWNLOAD MANAGER] Processing queue: 1734567891-def456ghi (4 remaining)
|
||||
[DOWNLOAD MANAGER] Starting queued file: video2.mp4 (8.1GB)
|
||||
```
|
||||
|
||||
### System Benefits
|
||||
|
||||
**User Experience**
|
||||
|
||||
- Users don't receive errors, they simply wait in queue
|
||||
- Downloads start automatically when slots become available
|
||||
- Transparent operation without client changes
|
||||
- Fair processing order with FIFO queue
|
||||
|
||||
**Technical Features**
|
||||
|
||||
- Limited buffers (64KB per stream) for controlled memory usage
|
||||
- Automatic backpressure control with pipeline streams
|
||||
- Adaptive memory throttling based on usage patterns
|
||||
- Forced garbage collection after large downloads
|
||||
- Smart timeout handling (30 minutes for queued downloads)
|
||||
- Automatic cleanup of orphaned downloads every 30 seconds
|
||||
|
||||
## Container Compatibility
|
||||
|
||||
The system works with Docker, Kubernetes, and any containerized environment:
|
||||
|
||||
<Tabs items={["Docker", "Kubernetes", "Docker Compose"]}>
|
||||
<Tab value="Docker">
|
||||
|
||||
```bash
|
||||
# Example: Container with 8GB
|
||||
docker run -m 8g palmr/server
|
||||
# Result: 5 concurrent downloads, queue of 25, threshold 2GB
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab value="Kubernetes">
|
||||
|
||||
```yaml
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- name: palmr-server
|
||||
resources:
|
||||
limits:
|
||||
memory: "4Gi" # Detects 4GB
|
||||
cpu: "2"
|
||||
requests:
|
||||
memory: "2Gi"
|
||||
cpu: "1"
|
||||
# Result: 3 concurrent downloads, queue of 15, threshold 1GB
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab value="Docker Compose">
|
||||
|
||||
```yaml
|
||||
services:
|
||||
palmr-server:
|
||||
image: palmr/server
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
memory: 16G # Detects 16GB
|
||||
# Result: 10 concurrent downloads, queue of 50, threshold 4GB
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
## Configuration
|
||||
|
||||
### Environment Variables
|
||||
|
||||
Configure the download memory management system using these environment variables:
|
||||
|
||||
| Variable | Default | Description |
|
||||
| ------------------------------ | ---------- | ----------------------------------------------------- |
|
||||
| `DOWNLOAD_MAX_CONCURRENT` | auto-scale | Maximum number of simultaneous downloads |
|
||||
| `DOWNLOAD_MEMORY_THRESHOLD_MB` | auto-scale | Memory limit in MB before throttling |
|
||||
| `DOWNLOAD_QUEUE_SIZE` | auto-scale | Maximum download queue size |
|
||||
| `DOWNLOAD_AUTO_SCALE` | `true` | Enable/disable auto-scaling based on system memory |
|
||||
| `DOWNLOAD_MIN_FILE_SIZE_GB` | `3.0` | Minimum file size in GB to activate memory management |
|
||||
|
||||
### Configuration Examples by Scenario
|
||||
|
||||
<Tabs items={["Home Server", "Enterprise", "High Performance", "Conservative"]}>
|
||||
<Tab value="Home Server">
|
||||
Configuration optimized for personal use or small groups (4GB RAM):
|
||||
|
||||
```bash
|
||||
DOWNLOAD_MAX_CONCURRENT=2
|
||||
DOWNLOAD_MEMORY_THRESHOLD_MB=1024
|
||||
DOWNLOAD_QUEUE_SIZE=8
|
||||
DOWNLOAD_MIN_FILE_SIZE_GB=2.0
|
||||
DOWNLOAD_AUTO_SCALE=false
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab value="Enterprise">
|
||||
Configuration for corporate environments with multiple users (16GB RAM):
|
||||
|
||||
```bash
|
||||
DOWNLOAD_MAX_CONCURRENT=12
|
||||
DOWNLOAD_MEMORY_THRESHOLD_MB=4096
|
||||
DOWNLOAD_QUEUE_SIZE=60
|
||||
DOWNLOAD_MIN_FILE_SIZE_GB=5.0
|
||||
DOWNLOAD_AUTO_SCALE=false
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab value="High Performance">
|
||||
Configuration for maximum performance and throughput (32GB RAM):
|
||||
|
||||
```bash
|
||||
DOWNLOAD_MAX_CONCURRENT=20
|
||||
DOWNLOAD_MEMORY_THRESHOLD_MB=8192
|
||||
DOWNLOAD_QUEUE_SIZE=100
|
||||
DOWNLOAD_MIN_FILE_SIZE_GB=10.0
|
||||
DOWNLOAD_AUTO_SCALE=false
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab value="Conservative">
|
||||
For environments with limited or shared resources:
|
||||
|
||||
```bash
|
||||
DOWNLOAD_MAX_CONCURRENT=3
|
||||
DOWNLOAD_MEMORY_THRESHOLD_MB=1024
|
||||
DOWNLOAD_QUEUE_SIZE=15
|
||||
DOWNLOAD_MIN_FILE_SIZE_GB=1.0
|
||||
DOWNLOAD_AUTO_SCALE=false
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
### Additional Configuration
|
||||
|
||||
For optimal performance with large downloads, consider these additional settings:
|
||||
|
||||
```bash
|
||||
# Force garbage collection (recommended for large downloads)
|
||||
NODE_OPTIONS="--expose-gc"
|
||||
|
||||
# Adjust timeout for very large downloads
|
||||
KEEP_ALIVE_TIMEOUT=300000
|
||||
REQUEST_TIMEOUT=0
|
||||
```
|
||||
|
||||
## Monitoring and Logs
|
||||
|
||||
### System Logs
|
||||
|
||||
The system provides detailed logs to track operation:
|
||||
|
||||
```bash
|
||||
[DOWNLOAD MANAGER] System Memory: 8.0GB, Max Concurrent: 5, Memory Threshold: 2048MB, Queue Size: 25
|
||||
[DOWNLOAD] Requesting slot for 1734567890-abc123def: video.mp4 (15.2GB)
|
||||
[DOWNLOAD MANAGER] Queued: 1734567890-abc123def (Position: 3/25)
|
||||
[DOWNLOAD MANAGER] Processing queue: 1734567890-abc123def (2 remaining)
|
||||
[DOWNLOAD] Starting 1734567890-abc123def: video.mp4 (15.2GB)
|
||||
[MEMORY THROTTLE] video.mp4 - Pausing stream due to high memory usage: 1843MB
|
||||
[DOWNLOAD] Applying throttling: 100ms delay for 1734567890-abc123def
|
||||
```
|
||||
|
||||
### Configuration Validation
|
||||
|
||||
The system automatically validates configurations at startup and provides warnings or errors:
|
||||
|
||||
**Warnings**
|
||||
|
||||
- `DOWNLOAD_MAX_CONCURRENT > 50`: May cause performance issues
|
||||
- `DOWNLOAD_MEMORY_THRESHOLD_MB < 128MB`: Downloads may be throttled frequently
|
||||
- `DOWNLOAD_MEMORY_THRESHOLD_MB > 16GB`: System may run out of memory
|
||||
- `DOWNLOAD_QUEUE_SIZE > 1000`: May consume significant memory
|
||||
- `DOWNLOAD_QUEUE_SIZE < DOWNLOAD_MAX_CONCURRENT`: Queue smaller than concurrent downloads
|
||||
|
||||
**Errors**
|
||||
|
||||
- `DOWNLOAD_MAX_CONCURRENT < 1`: Invalid value
|
||||
- `DOWNLOAD_QUEUE_SIZE < 1`: Invalid value
|
||||
|
||||
## Queue Management APIs
|
||||
|
||||
The system provides REST APIs to monitor and manage the download queue:
|
||||
|
||||
### Get Queue Status
|
||||
|
||||
```http
|
||||
GET /api/filesystem/download-queue/status
|
||||
```
|
||||
|
||||
**Response:**
|
||||
|
||||
```json
|
||||
{
|
||||
"data": {
|
||||
"queueLength": 3,
|
||||
"maxQueueSize": 25,
|
||||
"activeDownloads": 5,
|
||||
"maxConcurrent": 5,
|
||||
"queuedDownloads": [
|
||||
{
|
||||
"downloadId": "1734567890-abc123def",
|
||||
"position": 1,
|
||||
"waitTime": 45000,
|
||||
"fileName": "video.mp4",
|
||||
"fileSize": 16106127360
|
||||
}
|
||||
]
|
||||
},
|
||||
"status": "success"
|
||||
}
|
||||
```
|
||||
|
||||
### Cancel Download
|
||||
|
||||
```http
|
||||
DELETE /api/filesystem/download-queue/{downloadId}
|
||||
```
|
||||
|
||||
**Response:**
|
||||
|
||||
```json
|
||||
{
|
||||
"downloadId": "1734567890-abc123def",
|
||||
"message": "Download cancelled successfully"
|
||||
}
|
||||
```
|
||||
|
||||
### Clear Queue (Admin)
|
||||
|
||||
```http
|
||||
DELETE /api/filesystem/download-queue
|
||||
```
|
||||
|
||||
**Response:**
|
||||
|
||||
```json
|
||||
{
|
||||
"clearedCount": 8,
|
||||
"message": "Download queue cleared successfully"
|
||||
}
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Common Issues
|
||||
|
||||
**Downloads failing with "Download queue is full"**
|
||||
|
||||
_Cause:_ Too many simultaneous downloads with a full queue
|
||||
|
||||
_Solutions:_
|
||||
|
||||
- Wait for some downloads to finish
|
||||
- Check for orphaned downloads in queue
|
||||
- Consider increasing container resources
|
||||
- Use API to clear queue if necessary
|
||||
|
||||
**Downloads stay too long in queue**
|
||||
|
||||
_Cause:_ Active downloads are slow or stuck
|
||||
|
||||
_Solutions:_
|
||||
|
||||
- Check logs for orphaned downloads
|
||||
- Use API to cancel specific downloads
|
||||
- Check client network connections
|
||||
- Monitor memory throttling
|
||||
|
||||
**Very slow downloads**
|
||||
|
||||
_Cause:_ Active throttling due to high memory usage
|
||||
|
||||
_Solutions:_
|
||||
|
||||
- Check other processes consuming memory
|
||||
- Consider increasing container resources
|
||||
- Monitor throttling logs
|
||||
- Check number of simultaneous downloads
|
||||
|
||||
## Summary
|
||||
|
||||
This system enables unlimited downloads (including 50TB+ files) without compromising system stability through:
|
||||
|
||||
**Key Features**
|
||||
|
||||
- Auto-configuration based on available resources
|
||||
- Automatic FIFO queue system for pending downloads
|
||||
- Adaptive control of simultaneous downloads
|
||||
- Intelligent throttling when needed
|
||||
|
||||
**System Benefits**
|
||||
|
||||
- Management APIs to monitor and control queue
|
||||
- Automatic cleanup of resources and orphaned downloads
|
||||
- Full compatibility with Docker/Kubernetes
|
||||
- Perfect user experience with no 429 errors
|
||||
|
||||
The system maintains high performance for small/medium files while preventing crashes with gigantic files, offering a seamless experience where users never see 429 errors, they simply wait in queue until their download starts automatically.
|
@@ -49,6 +49,7 @@ The frontend is organized with:
|
||||
- **Custom hooks** to isolate logic and side effects
|
||||
- A **route protection system** using session cookies and middleware
|
||||
- A **file management interface** integrated with the backend
|
||||
- **Folder support** for organizing files hierarchically
|
||||
- A **reusable modal system** used for file actions, confirmations, and more
|
||||
- **Dynamic, locale-aware routing** using next-intl
|
||||
|
||||
@@ -68,7 +69,7 @@ Data is stored in **SQLite**, which handles user info, file metadata, session to
|
||||
Key features include:
|
||||
|
||||
- **Authentication/authorization** with JWT + cookie sessions
|
||||
- **File management logic** including uploads, deletes, and renames
|
||||
- **File management logic** including uploads, deletes, renames, and folders
|
||||
- **Storage operations** to handle file organization, usage tracking, and cleanup
|
||||
- A **share system** that generates tokenized public file links
|
||||
- Schema-based request validation for all endpoints
|
||||
@@ -106,9 +107,10 @@ Volumes are used to persist data locally, and containers are networked together
|
||||
|
||||
### File management
|
||||
|
||||
Files are at the heart of Palmr. Users can upload files via the frontend, and they're stored directly in the filesystem. The backend handles metadata (name, size, type, ownership), and also handles deletion, renaming, and public sharing. Every file operation is tracked, and all actions can be scoped per user.
|
||||
Files are at the heart of Palmr. Users can upload files via the frontend, and they're stored directly in the filesystem. Users can also create folders to organize files. The backend handles metadata (name, size, type, ownership), and also handles deletion, renaming, and public sharing. Every file operation is tracked, and all actions can be scoped per user.
|
||||
|
||||
- Upload/download with instant feedback
|
||||
- Create and organize files in folders
|
||||
- File previews, type validation, and size limits
|
||||
- Token-based sharing system
|
||||
- Disk usage tracking by user
|
@@ -5,7 +5,7 @@ icon: Cog
|
||||
|
||||
Hey there! Looking to run **Palmr.** your way, with complete control over every piece of the stack? This manual installation guide is for you. No Docker, no pre-built containers just the raw source code to tweak, customize, and deploy as you see fit.
|
||||
|
||||
> **Prefer a quicker setup?** If this hands-on approach feels like overkill, check out our [**Quick Start (Docker)**](/docs/3.1-beta/quick-start) guide for a fast, containerized deployment. This manual path is tailored for developers who want to dive deep, modify the codebase, or integrate custom services.
|
||||
> **Prefer a quicker setup?** If this hands-on approach feels like overkill, check out our [**Quick Start (Docker)**](/docs/3.2-beta/quick-start) guide for a fast, containerized deployment. This manual path is tailored for developers who want to dive deep, modify the codebase, or integrate custom services.
|
||||
|
||||
Here's what you'll do at a glance:
|
||||
|
||||
@@ -165,6 +165,27 @@ cp .env.example .env
|
||||
|
||||
This creates a `.env` file with the necessary configurations for the frontend.
|
||||
|
||||
##### Upload Configuration
|
||||
|
||||
Palmr. supports configurable chunked uploading for large files. You can customize the chunk size by setting the following environment variable in your `.env` file:
|
||||
|
||||
```bash
|
||||
NEXT_PUBLIC_UPLOAD_CHUNK_SIZE_MB=100
|
||||
```
|
||||
|
||||
**How it works:**
|
||||
|
||||
- If `NEXT_PUBLIC_UPLOAD_CHUNK_SIZE_MB` is set, Palmr. will use this value (in megabytes) as the chunk size for all file uploads that exceed this threshold.
|
||||
- If not set or left empty, Palmr. automatically calculates optimal chunk sizes based on file size:
|
||||
- Files ≤ 100MB: uploaded without chunking
|
||||
- Files > 100MB and ≤ 1GB: 75MB chunks
|
||||
- Files > 1GB: 150MB chunks
|
||||
|
||||
**When to configure:**
|
||||
|
||||
- **Default (not set):** Recommended for most use cases. Palmr. will intelligently determine the best chunk size.
|
||||
- **Custom value:** Set this if you have specific network conditions or want to optimize for your infrastructure (e.g., slower connections may benefit from smaller chunks like 50MB, while fast networks can handle larger chunks like 200MB, or the upload size per payload may be limited by a proxy like Cloudflare)
|
||||
|
||||
#### Install dependencies
|
||||
|
||||
Install all the frontend dependencies:
|
||||
@@ -201,6 +222,17 @@ You should see the full Palmr. application ready to go!
|
||||
|
||||
This guide sets up Palmr. using the local file system for storage. Want to use an S3-compatible object storage instead? You can configure that in the `.env` file. Check the Palmr. documentation for details on setting up S3 storage just update the environment variables, then build and run as shown here.
|
||||
|
||||
### Custom Installation Paths and Symlinks
|
||||
|
||||
If you're using a custom installation setup with symlinks (for example, `/opt/palmr_data/uploads -> /mnt/data/uploads`), you might encounter issues with disk space detection. Palmr. includes a `CUSTOM_PATH` environment variable to handle these scenarios:
|
||||
|
||||
```bash
|
||||
# In your .env file (apps/server/.env)
|
||||
CUSTOM_PATH=/opt/palmr_data
|
||||
```
|
||||
|
||||
This tells Palmr. to check your custom path first when determining available disk space, ensuring proper detection even when using symlinks or non-standard directory structures.
|
||||
|
||||
---
|
||||
|
||||
## Command cheat sheet
|
||||
@@ -232,10 +264,10 @@ pnpm serve
|
||||
|
||||
Palmr. is now up and running locally . Here are some suggested next steps:
|
||||
|
||||
- **Manage Users**: Dive into the [Users Management](/docs/3.1-beta/manage-users) guide.
|
||||
- **Manage Users**: Dive into the [Users Management](/docs/3.2-beta/manage-users) guide.
|
||||
- **Switch to Object Storage**: Update `.env` variables to use an S3-compatible bucket (see Quick Notes above).
|
||||
- **Secure Your Instance**: Put Palmr. behind a reverse proxy like **Nginx** or **Caddy** and enable HTTPS.
|
||||
- **Learn the Internals**: Explore how everything connects in the [Architecture](/docs/3.1-beta/architecture) overview.
|
||||
- **Learn the Internals**: Explore how everything connects in the [Architecture](/docs/3.2-beta/architecture) overview.
|
||||
|
||||
Jump into whichever area fits your needs our docs are designed for exploration in any order.
|
||||
|
@@ -14,7 +14,9 @@
|
||||
"available-languages",
|
||||
"uid-gid-configuration",
|
||||
"reverse-proxy-configuration",
|
||||
"download-memory-management",
|
||||
"password-reset-without-smtp",
|
||||
"cleanup-orphan-files",
|
||||
"oidc-authentication",
|
||||
"troubleshooting",
|
||||
"---Developers---",
|
||||
@@ -29,5 +31,5 @@
|
||||
"gh-sponsor"
|
||||
],
|
||||
"root": true,
|
||||
"title": "v3.1-beta"
|
||||
"title": "v3.2-beta"
|
||||
}
|
@@ -360,7 +360,7 @@ With Auth0 authentication configured, you might want to:
|
||||
- **Review security settings**: Ensure your authentication setup meets your security requirements
|
||||
- **Monitor usage**: Keep track of authentication patterns and user activity
|
||||
|
||||
For more information about OIDC authentication in Palmr, see the [OIDC Authentication overview](/docs/3.1-beta/oidc-authentication).
|
||||
For more information about OIDC authentication in Palmr, see the [OIDC Authentication overview](/docs/3.2-beta/oidc-authentication).
|
||||
|
||||
## Useful resources
|
||||
|
@@ -374,7 +374,7 @@ With Authentik authentication configured, you might want to:
|
||||
- **Review security settings**: Ensure your authentication setup meets your security requirements
|
||||
- **Monitor usage**: Keep track of authentication patterns and user activity
|
||||
|
||||
For more information about OIDC authentication in Palmr, see the [OIDC Authentication overview](/docs/3.1-beta/oidc-authentication).
|
||||
For more information about OIDC authentication in Palmr, see the [OIDC Authentication overview](/docs/3.2-beta/oidc-authentication).
|
||||
|
||||
## Useful resources
|
||||
|
@@ -332,7 +332,7 @@ With Discord authentication configured, you might want to:
|
||||
- **Review security settings**: Ensure your authentication setup meets your security requirements
|
||||
- **Monitor usage**: Keep track of authentication patterns and user activity
|
||||
|
||||
For more information about OIDC authentication in Palmr, see the [OIDC Authentication overview](/docs/3.1-beta/oidc-authentication).
|
||||
For more information about OIDC authentication in Palmr, see the [OIDC Authentication overview](/docs/3.2-beta/oidc-authentication).
|
||||
|
||||
## Useful resources
|
||||
|
@@ -314,7 +314,7 @@ With Frontegg authentication configured, you might want to:
|
||||
- **Review security settings**: Ensure your authentication setup meets your security requirements
|
||||
- **Monitor usage**: Keep track of authentication patterns and user activity
|
||||
|
||||
For more information about OIDC authentication in Palmr, see the [OIDC Authentication overview](/docs/3.1-beta/oidc-authentication).
|
||||
For more information about OIDC authentication in Palmr, see the [OIDC Authentication overview](/docs/3.2-beta/oidc-authentication).
|
||||
|
||||
## Useful resources
|
||||
|
@@ -295,7 +295,7 @@ With GitHub authentication configured, you might want to:
|
||||
- **Review security settings**: Ensure your authentication setup meets your security requirements
|
||||
- **Monitor usage**: Keep track of authentication patterns and user activity
|
||||
|
||||
For more information about OIDC authentication in Palmr, see the [OIDC Authentication overview](/docs/3.1-beta/oidc-authentication).
|
||||
For more information about OIDC authentication in Palmr, see the [OIDC Authentication overview](/docs/3.2-beta/oidc-authentication).
|
||||
|
||||
## Useful resources
|
||||
|
@@ -325,7 +325,7 @@ With Google authentication configured, you might want to:
|
||||
- **Review security settings**: Ensure your authentication setup meets your security requirements
|
||||
- **Monitor usage**: Keep track of authentication patterns and user activity
|
||||
|
||||
For more information about OIDC authentication in Palmr, see the [OIDC Authentication overview](/docs/3.1-beta/oidc-authentication).
|
||||
For more information about OIDC authentication in Palmr, see the [OIDC Authentication overview](/docs/3.2-beta/oidc-authentication).
|
||||
|
||||
## Useful resources
|
||||
|
@@ -38,14 +38,14 @@ Before configuring OIDC authentication, ensure you have:
|
||||
|
||||
Palmr's OIDC implementation is compatible with any OpenID Connect compliant provider, including as official providers:
|
||||
|
||||
- **[Google](/docs/3.1-beta/oidc-authentication/google)**
|
||||
- **[Discord](/docs/3.1-beta/oidc-authentication/discord)**
|
||||
- **[Github](/docs/3.1-beta/oidc-authentication/github)**
|
||||
- **[Zitadel](/docs/3.1-beta/oidc-authentication/zitadel)**
|
||||
- **[Auth0](/docs/3.1-beta/oidc-authentication/auth0)**
|
||||
- **[Authentik](/docs/3.1-beta/oidc-authentication/authentik)**
|
||||
- **[Frontegg](/docs/3.1-beta/oidc-authentication/frontegg)**
|
||||
- **[Kinde Auth](/docs/3.1-beta/oidc-authentication/kinde-auth)**
|
||||
- **[Google](/docs/3.2-beta/oidc-authentication/google)**
|
||||
- **[Discord](/docs/3.2-beta/oidc-authentication/discord)**
|
||||
- **[Github](/docs/3.2-beta/oidc-authentication/github)**
|
||||
- **[Zitadel](/docs/3.2-beta/oidc-authentication/zitadel)**
|
||||
- **[Auth0](/docs/3.2-beta/oidc-authentication/auth0)**
|
||||
- **[Authentik](/docs/3.2-beta/oidc-authentication/authentik)**
|
||||
- **[Frontegg](/docs/3.2-beta/oidc-authentication/frontegg)**
|
||||
- **[Kinde Auth](/docs/3.2-beta/oidc-authentication/kinde-auth)**
|
||||
|
||||
Although these are the official providers (internally tested with 100% success), you can connect any OIDC provider by providing your credentials and connection URL. We've developed a practical way to integrate virtually all OIDC providers available in the market. In this documentation, you can consult how to configure each of the official providers, as well as include other providers not listed as official. Just below, you will find instructions on how to access the OIDC provider configuration. For specific details about configuring each provider, select the desired option in the sidebar, in the "OIDC Authentication" section.
|
||||
|
@@ -359,7 +359,7 @@ With Kinde Auth authentication configured, you might want to:
|
||||
- **Review security settings**: Ensure your authentication setup meets your security requirements
|
||||
- **Monitor usage**: Keep track of authentication patterns and user activity
|
||||
|
||||
For more information about OIDC authentication in Palmr, see the [OIDC Authentication overview](/docs/3.1-beta/oidc-authentication).
|
||||
For more information about OIDC authentication in Palmr, see the [OIDC Authentication overview](/docs/3.2-beta/oidc-authentication).
|
||||
|
||||
## Useful resources
|
||||
|
@@ -15,4 +15,4 @@
|
||||
"other"
|
||||
],
|
||||
"title": "OIDC Authentication"
|
||||
}
|
||||
}
|
@@ -270,10 +270,10 @@ After configuring Pocket ID authentication:
|
||||
- **User management**: Review auto-registration settings
|
||||
- **Backup verification**: Test backup and restore procedures
|
||||
|
||||
For more information about OIDC authentication in Palmr, see the [OIDC Authentication overview](/docs/3.1-beta/oidc-authentication).
|
||||
For more information about OIDC authentication in Palmr, see the [OIDC Authentication overview](/docs/3.2-beta/oidc-authentication).
|
||||
|
||||
## Useful resources
|
||||
|
||||
- [Pocket ID Documentation](https://docs.pocket-id.org)
|
||||
- [OIDC Specification](https://openid.net/specs/openid-connect-core-1_0.html)
|
||||
- [Palmr OIDC Overview](/docs/3.1-beta/oidc-authentication)
|
||||
- [Palmr OIDC Overview](/docs/3.2-beta/oidc-authentication)
|
@@ -413,7 +413,7 @@ With Zitadel authentication configured, you might want to:
|
||||
- **Review security settings**: Ensure your authentication setup meets your security requirements
|
||||
- **Monitor usage**: Keep track of authentication patterns and user activity
|
||||
|
||||
For more information about OIDC authentication in Palmr, see the [OIDC Authentication overview](/docs/3.1-beta/oidc-authentication).
|
||||
For more information about OIDC authentication in Palmr, see the [OIDC Authentication overview](/docs/3.2-beta/oidc-authentication).
|
||||
|
||||
## Useful resources
|
||||
|
@@ -69,6 +69,14 @@ Choose your storage method based on your needs:
|
||||
# - PALMR_GID=1000 # GID for the container processes (default is 1000)
|
||||
# - SECURE_SITE=false # Set to true if you are using a reverse proxy
|
||||
# - DEFAULT_LANGUAGE=en-US # Default language for the application (optional, defaults to en-US)
|
||||
# - PRESIGNED_URL_EXPIRATION=3600 # Duration in seconds for presigned URL expiration (optional, defaults to 3600 seconds / 1 hour)
|
||||
# - DOWNLOAD_MAX_CONCURRENT=5 # Maximum simultaneous downloads (auto-scales if not set)
|
||||
# - DOWNLOAD_MEMORY_THRESHOLD_MB=2048 # Memory threshold in MB before throttling (auto-scales if not set)
|
||||
# - DOWNLOAD_QUEUE_SIZE=25 # Maximum queue size for pending downloads (auto-scales if not set)
|
||||
# - DOWNLOAD_MIN_FILE_SIZE_GB=3.0 # Minimum file size in GB to activate memory management (default: 3.0)
|
||||
# - DOWNLOAD_AUTO_SCALE=true # Enable auto-scaling based on system memory (default: true)
|
||||
# - NODE_OPTIONS=--expose-gc # Enable garbage collection for large downloads (recommended for production)
|
||||
# - NEXT_PUBLIC_UPLOAD_CHUNK_SIZE_MB=100 # Chunk size in MB for large file uploads (OPTIONAL - auto-calculates if not set)
|
||||
volumes:
|
||||
- palmr_data:/app/server
|
||||
|
||||
@@ -77,7 +85,7 @@ Choose your storage method based on your needs:
|
||||
```
|
||||
|
||||
<Callout type="info">
|
||||
**Having upload or permission issues?** Add `PALMR_UID=1000` and `PALMR_GID=1000` to your environment variables. Check our [UID/GID Configuration](/docs/3.1-beta/uid-gid-configuration) guide for more details.
|
||||
**Having upload or permission issues?** Add `PALMR_UID=1000` and `PALMR_GID=1000` to your environment variables. Check our [UID/GID Configuration](/docs/3.2-beta/uid-gid-configuration) guide for more details.
|
||||
</Callout>
|
||||
|
||||
### Deploy
|
||||
@@ -106,7 +114,7 @@ Choose your storage method based on your needs:
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "5487:5487" # Web interface
|
||||
# - "3333:3333" # API (optional)
|
||||
# - "3333:3333" # API (optional)
|
||||
environment:
|
||||
# Optional: Uncomment and configure as needed (if you don`t use, you can remove)
|
||||
# - ENABLE_S3=true # Set to true to enable S3-compatible storage
|
||||
@@ -116,12 +124,19 @@ Choose your storage method based on your needs:
|
||||
# - PALMR_GID=1000 # GID for the container processes (default is 1000)
|
||||
# - SECURE_SITE=false # Set to true if you are using a reverse proxy
|
||||
# - DEFAULT_LANGUAGE=en-US # Default language for the application (optional, defaults to en-US)
|
||||
# - PRESIGNED_URL_EXPIRATION=3600 # Duration in seconds for presigned URL expiration (optional, defaults to 3600 seconds / 1 hour)
|
||||
# - DOWNLOAD_MAX_CONCURRENT=5 # Maximum simultaneous downloads (auto-scales if not set)
|
||||
# - DOWNLOAD_MEMORY_THRESHOLD_MB=2048 # Memory threshold in MB before throttling (auto-scales if not set)
|
||||
# - DOWNLOAD_QUEUE_SIZE=25 # Maximum queue size for pending downloads (auto-scales if not set)
|
||||
# - DOWNLOAD_MIN_FILE_SIZE_GB=3.0 # Minimum file size in GB to activate memory management (default: 3.0)
|
||||
# - DOWNLOAD_AUTO_SCALE=true # Enable auto-scaling based on system memory (default: true)
|
||||
# - NODE_OPTIONS=--expose-gc # Enable garbage collection for large downloads (recommended for production)
|
||||
volumes:
|
||||
- ./data:/app/server
|
||||
```
|
||||
|
||||
<Callout type="info">
|
||||
**Having upload or permission issues?** Add `PALMR_UID=1000` and `PALMR_GID=1000` to your environment variables. Check our [UID/GID Configuration](/docs/3.1-beta/uid-gid-configuration) guide for more details.
|
||||
**Having upload or permission issues?** Add `PALMR_UID=1000` and `PALMR_GID=1000` to your environment variables. Check our [UID/GID Configuration](/docs/3.2-beta/uid-gid-configuration) guide for more details.
|
||||
</Callout>
|
||||
|
||||
### Deploy
|
||||
@@ -137,15 +152,33 @@ Choose your storage method based on your needs:
|
||||
|
||||
Customize Palmr's behavior with these environment variables:
|
||||
|
||||
| Variable | Default | Description |
|
||||
| ------------------------------- | ------- | -------------------------------------------------------------------------------------------- |
|
||||
| `ENABLE_S3` | `false` | Enable S3-compatible storage backends |
|
||||
| `ENCRYPTION_KEY` | - | **Required when encryption is enabled**: 32+ character key for file encryption |
|
||||
| `DISABLE_FILESYSTEM_ENCRYPTION` | `true` | Disable file encryption for better performance (set to `false` to enable encryption) |
|
||||
| `SECURE_SITE` | `false` | Enable secure cookies for HTTPS/reverse proxy deployments |
|
||||
| `DEFAULT_LANGUAGE` | `en-US` | Default application language ([see available languages](/docs/3.1-beta/available-languages)) |
|
||||
| `PALMR_UID` | `1000` | User ID for container processes (helps with file permissions) |
|
||||
| `PALMR_GID` | `1000` | Group ID for container processes (helps with file permissions) |
|
||||
| Variable | Default | Description |
|
||||
| ---------------------------------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `ENABLE_S3` | `false` | Enable S3-compatible storage backends |
|
||||
| `S3_ENDPOINT` | - | S3 server endpoint URL (required when using S3) |
|
||||
| `S3_PORT` | - | S3 server port (optional when using S3) |
|
||||
| `S3_USE_SSL` | - | Enable SSL for S3 connections (optional when using S3) |
|
||||
| `S3_ACCESS_KEY` | - | S3 access key for authentication (required when using S3) |
|
||||
| `S3_SECRET_KEY` | - | S3 secret key for authentication (required when using S3) |
|
||||
| `S3_REGION` | - | S3 region configuration (optional when using S3) |
|
||||
| `S3_BUCKET_NAME` | - | S3 bucket name for file storage (required when using S3) |
|
||||
| `S3_FORCE_PATH_STYLE` | `false` | Force path-style S3 URLs (optional when using S3) |
|
||||
| `S3_REJECT_UNAUTHORIZED` | `true` | Enable strict SSL certificate validation for S3 (set to `false` for self-signed certificates) |
|
||||
| `ENCRYPTION_KEY` | - | **Required when encryption is enabled**: 32+ character key for file encryption |
|
||||
| `DISABLE_FILESYSTEM_ENCRYPTION` | `true` | Disable file encryption for better performance (set to `false` to enable encryption) |
|
||||
| `PRESIGNED_URL_EXPIRATION` | `3600` | Duration in seconds for presigned URL expiration (applies to both filesystem and S3 storage) |
|
||||
| `CUSTOM_PATH` | - | Custom base path for disk space detection in manual installations with symlinks |
|
||||
| `SECURE_SITE` | `false` | Enable secure cookies for HTTPS/reverse proxy deployments |
|
||||
| `DEFAULT_LANGUAGE` | `en-US` | Default application language ([see available languages](/docs/3.2-beta/available-languages)) |
|
||||
| `PALMR_UID` | `1000` | User ID for container processes (helps with file permissions) |
|
||||
| `PALMR_GID` | `1000` | Group ID for container processes (helps with file permissions) |
|
||||
| `NODE_OPTIONS` | - | Node.js options (recommended: `--expose-gc` for garbage collection in production) |
|
||||
| `DOWNLOAD_MAX_CONCURRENT` | auto-scale | Maximum number of simultaneous downloads (see [Download Memory Management](/docs/3.2-beta/download-memory-management)) |
|
||||
| `DOWNLOAD_MEMORY_THRESHOLD_MB` | auto-scale | Memory threshold in MB before throttling |
|
||||
| `DOWNLOAD_QUEUE_SIZE` | auto-scale | Maximum queue size for pending downloads |
|
||||
| `DOWNLOAD_MIN_FILE_SIZE_GB` | `3.0` | Minimum file size in GB to activate memory management |
|
||||
| `NEXT_PUBLIC_UPLOAD_CHUNK_SIZE_MB` | auto-calculate | Chunk size in MB for large file uploads (see [Chunked Upload Configuration](/docs/3.2-beta/quick-start#chunked-upload-configuration)) |
|
||||
| `DOWNLOAD_AUTO_SCALE` | `true` | Enable auto-scaling based on system memory |
|
||||
|
||||
<Callout type="info">
|
||||
**Performance First**: Palmr runs without encryption by default for optimal speed and lower resource usage—perfect for
|
||||
@@ -160,7 +193,7 @@ Customize Palmr's behavior with these environment variables:
|
||||
|
||||
<Callout>
|
||||
**Using a Reverse Proxy?** Set `SECURE_SITE=true` and check our [Reverse Proxy
|
||||
Configuration](/docs/3.1-beta/reverse-proxy-configuration) guide for proper HTTPS setup.
|
||||
Configuration](/docs/3.2-beta/reverse-proxy-configuration) guide for proper HTTPS setup.
|
||||
</Callout>
|
||||
|
||||
### Generate Encryption Keys (Optional)
|
||||
@@ -180,7 +213,7 @@ Once deployed, open Palmr in your browser:
|
||||
|
||||
<Callout type="info">
|
||||
**Learn More**: For complete API documentation, authentication, and integration examples, see our [API
|
||||
Reference](/docs/3.1-beta/api) guide
|
||||
Reference](/docs/3.2-beta/api) guide
|
||||
</Callout>
|
||||
|
||||
<Callout type="warn">
|
||||
@@ -216,7 +249,7 @@ Prefer Docker commands over Compose? Here are the equivalent commands:
|
||||
|
||||
|
||||
<Callout type="info">
|
||||
**Permission Issues?** Add `-e PALMR_UID=1000 -e PALMR_GID=1000` to the command above. See our [UID/GID Configuration](/docs/3.1-beta/uid-gid-configuration) guide for details.
|
||||
**Permission Issues?** Add `-e PALMR_UID=1000 -e PALMR_GID=1000` to the command above. See our [UID/GID Configuration](/docs/3.2-beta/uid-gid-configuration) guide for details.
|
||||
</Callout>
|
||||
|
||||
</Tab>
|
||||
@@ -242,7 +275,7 @@ Prefer Docker commands over Compose? Here are the equivalent commands:
|
||||
```
|
||||
|
||||
<Callout type="info">
|
||||
**Permission Issues?** Add `-e PALMR_UID=1000 -e PALMR_GID=1000` to the command above. See our [UID/GID Configuration](/docs/3.1-beta/uid-gid-configuration) guide for details.
|
||||
**Permission Issues?** Add `-e PALMR_UID=1000 -e PALMR_GID=1000` to the command above. See our [UID/GID Configuration](/docs/3.2-beta/uid-gid-configuration) guide for details.
|
||||
</Callout>
|
||||
|
||||
</Tab>
|
||||
@@ -250,6 +283,63 @@ Prefer Docker commands over Compose? Here are the equivalent commands:
|
||||
|
||||
---
|
||||
|
||||
## Common Configuration Options
|
||||
|
||||
### Presigned URL Expiration
|
||||
|
||||
Palmr. uses temporary URLs (presigned URLs) for secure file access. These URLs expire after a configurable time period to enhance security.
|
||||
|
||||
**Default:** 1 hour (3600 seconds)
|
||||
|
||||
You can customize this for all storage types (filesystem or S3) by adding:
|
||||
|
||||
```yaml
|
||||
environment:
|
||||
- PRESIGNED_URL_EXPIRATION=7200 # 2 hours
|
||||
```
|
||||
|
||||
**When to adjust:**
|
||||
|
||||
- **Shorter time (1800 = 30 min):** Higher security, but users may need to refresh download links
|
||||
- **Longer time (7200-21600 = 2-6 hours):** Better for large file transfers, but URLs stay valid longer
|
||||
- **Default (3600 = 1 hour):** Good balance for most use cases
|
||||
|
||||
### File Encryption
|
||||
|
||||
For filesystem storage, you can enable file encryption:
|
||||
|
||||
```yaml
|
||||
environment:
|
||||
- DISABLE_FILESYSTEM_ENCRYPTION=false
|
||||
- ENCRYPTION_KEY=your-secure-32-character-key-here
|
||||
```
|
||||
|
||||
**Note:** S3 storage handles encryption through your S3 provider's encryption features.
|
||||
|
||||
### Chunked Upload Configuration
|
||||
|
||||
Palmr supports configurable chunked uploading for large files. You can customize the chunk size by setting the following environment variable:
|
||||
|
||||
```yaml
|
||||
environment:
|
||||
- NEXT_PUBLIC_UPLOAD_CHUNK_SIZE_MB=100 # Chunk size in MB
|
||||
```
|
||||
|
||||
**How it works:**
|
||||
|
||||
- If `NEXT_PUBLIC_UPLOAD_CHUNK_SIZE_MB` is set, Palmr will use this value (in megabytes) as the chunk size for all file uploads that exceed this threshold.
|
||||
- If not set or left empty, Palmr automatically calculates optimal chunk sizes based on file size:
|
||||
- Files ≤ 100MB: uploaded without chunking
|
||||
- Files > 100MB and ≤ 1GB: 75MB chunks
|
||||
- Files > 1GB: 150MB chunks
|
||||
|
||||
**When to configure:**
|
||||
|
||||
- **Default (not set):** Recommended for most use cases. Palmr will intelligently determine the best chunk size.
|
||||
- **Custom value:** Set this if you have specific network conditions or want to optimize for your infrastructure (e.g., slower connections may benefit from smaller chunks like 50MB, while fast networks can handle larger chunks like 200MB, or the upload size per payload may be limited by a proxy like Cloudflare)
|
||||
|
||||
---
|
||||
|
||||
## Maintenance
|
||||
|
||||
### Updates
|
||||
@@ -301,16 +391,17 @@ Your Palmr instance is ready! Here's what you can explore:
|
||||
|
||||
### Advanced Configuration
|
||||
|
||||
- **[UID/GID Configuration](/docs/3.1-beta/uid-gid-configuration)** - Configure user permissions for NAS systems and custom environments
|
||||
- **[S3 Storage](/docs/3.1-beta/s3-configuration)** - Scale with Amazon S3 or compatible storage providers
|
||||
- **[Manual Installation](/docs/3.1-beta/manual-installation)** - Manual installation and custom configurations
|
||||
- **[UID/GID Configuration](/docs/3.2-beta/uid-gid-configuration)** - Configure user permissions for NAS systems and custom environments
|
||||
- **[Download Memory Management](/docs/3.2-beta/download-memory-management)** - Configure large file download handling and queue system
|
||||
- **[S3 Storage](/docs/3.2-beta/s3-configuration)** - Scale with Amazon S3 or compatible storage providers
|
||||
- **[Manual Installation](/docs/3.2-beta/manual-installation)** - Manual installation and custom configurations
|
||||
|
||||
### Integration & Development
|
||||
|
||||
- **[API Reference](/docs/3.1-beta/api)** - Integrate Palmr. with your applications
|
||||
- **[API Reference](/docs/3.2-beta/api)** - Integrate Palmr. with your applications
|
||||
|
||||
<Callout type="info">
|
||||
**Need help?** Check our [Troubleshooting Guide](/docs/3.1-beta/troubleshooting) for common issues and solutions.
|
||||
**Need help?** Check our [Troubleshooting Guide](/docs/3.2-beta/troubleshooting) for common issues and solutions.
|
||||
</Callout>
|
||||
|
||||
---
|
@@ -131,7 +131,7 @@ environment:
|
||||
# - ENCRYPTION_KEY=your-key-here # Required only if encryption is enabled
|
||||
```
|
||||
|
||||
> **💡 Note**: Check your host UID/GID with `id` command and use those values. See [UID/GID Configuration](/docs/3.1-beta/uid-gid-configuration) for detailed setup.
|
||||
> **💡 Note**: Check your host UID/GID with `id` command and use those values. See [UID/GID Configuration](/docs/3.2-beta/uid-gid-configuration) for detailed setup.
|
||||
|
||||
---
|
||||
|
@@ -7,6 +7,8 @@ This guide provides comprehensive configuration instructions for integrating Pal
|
||||
|
||||
> **Overview:** Palmr. supports any S3-compatible storage provider, giving you flexibility to choose the solution that best fits your needs and budget.
|
||||
|
||||
> **Note:** Some configuration options (like presigned URL expiration) apply to **all storage types**, including filesystem storage. These are marked accordingly in the documentation.
|
||||
|
||||
## When to use S3-compatible storage
|
||||
|
||||
Consider using S3-compatible storage when you need:
|
||||
@@ -19,18 +21,27 @@ Consider using S3-compatible storage when you need:
|
||||
|
||||
## Environment variables
|
||||
|
||||
### General configuration (applies to all storage types)
|
||||
|
||||
| Variable | Description | Required | Default |
|
||||
| -------------------------- | ------------------------------------------------ | -------- | --------------- |
|
||||
| `PRESIGNED_URL_EXPIRATION` | Duration in seconds for presigned URL expiration | No | `3600` (1 hour) |
|
||||
|
||||
### S3-specific configuration
|
||||
|
||||
To enable S3-compatible storage, set `ENABLE_S3=true` and configure the following environment variables:
|
||||
|
||||
| Variable | Description | Required | Default |
|
||||
| --------------------- | ----------------------------- | -------- | ----------------- |
|
||||
| `S3_ENDPOINT` | S3 provider endpoint URL | Yes | - |
|
||||
| `S3_PORT` | Connection port | No | Based on protocol |
|
||||
| `S3_USE_SSL` | Enable SSL/TLS encryption | Yes | `true` |
|
||||
| `S3_ACCESS_KEY` | Access key for authentication | Yes | - |
|
||||
| `S3_SECRET_KEY` | Secret key for authentication | Yes | - |
|
||||
| `S3_REGION` | Storage region | Yes | - |
|
||||
| `S3_BUCKET_NAME` | Bucket/container name | Yes | - |
|
||||
| `S3_FORCE_PATH_STYLE` | Use path-style URLs | No | `false` |
|
||||
| Variable | Description | Required | Default |
|
||||
| ------------------------ | ---------------------------------------- | -------- | ----------------- |
|
||||
| `S3_ENDPOINT` | S3 provider endpoint URL | Yes | - |
|
||||
| `S3_PORT` | Connection port | No | Based on protocol |
|
||||
| `S3_USE_SSL` | Enable SSL/TLS encryption | Yes | `true` |
|
||||
| `S3_ACCESS_KEY` | Access key for authentication | Yes | - |
|
||||
| `S3_SECRET_KEY` | Secret key for authentication | Yes | - |
|
||||
| `S3_REGION` | Storage region | Yes | - |
|
||||
| `S3_BUCKET_NAME` | Bucket/container name | Yes | - |
|
||||
| `S3_FORCE_PATH_STYLE` | Use path-style URLs | No | `false` |
|
||||
| `S3_REJECT_UNAUTHORIZED` | Enable strict SSL certificate validation | No | `true` |
|
||||
|
||||
## Provider configurations
|
||||
|
||||
@@ -51,6 +62,7 @@ S3_SECRET_KEY=your-secret-access-key
|
||||
S3_REGION=us-east-1
|
||||
S3_BUCKET_NAME=your-bucket-name
|
||||
S3_FORCE_PATH_STYLE=false
|
||||
# PRESIGNED_URL_EXPIRATION=3600 # Optional: 1 hour (default)
|
||||
```
|
||||
|
||||
**Getting credentials:**
|
||||
@@ -81,6 +93,21 @@ S3_FORCE_PATH_STYLE=true
|
||||
- Default MinIO port is 9000
|
||||
- SSL can be disabled for local development
|
||||
|
||||
**For MinIO with self-signed SSL certificates:**
|
||||
|
||||
```bash
|
||||
ENABLE_S3=true
|
||||
S3_ENDPOINT=your-minio-domain.com
|
||||
S3_PORT=9000
|
||||
S3_USE_SSL=true
|
||||
S3_ACCESS_KEY=your-minio-access-key
|
||||
S3_SECRET_KEY=your-minio-secret-key
|
||||
S3_REGION=us-east-1
|
||||
S3_BUCKET_NAME=your-bucket-name
|
||||
S3_FORCE_PATH_STYLE=true
|
||||
S3_REJECT_UNAUTHORIZED=false # Allows self-signed certificates
|
||||
```
|
||||
|
||||
### Google Cloud Storage
|
||||
|
||||
Google Cloud Storage offers competitive pricing and global infrastructure.
|
||||
@@ -137,6 +164,7 @@ S3_SECRET_KEY=your-application-key
|
||||
S3_REGION=us-west-002
|
||||
S3_BUCKET_NAME=your-bucket-name
|
||||
S3_FORCE_PATH_STYLE=false
|
||||
# PRESIGNED_URL_EXPIRATION=7200 # Optional: 2 hours for large files
|
||||
```
|
||||
|
||||
**Cost advantage:**
|
||||
@@ -187,6 +215,93 @@ S3_FORCE_PATH_STYLE=false
|
||||
- Use container name as bucket name
|
||||
- Configure appropriate access policies
|
||||
|
||||
## Presigned URL configuration
|
||||
|
||||
Palmr. uses presigned URLs to provide secure, temporary access to files stored in **both S3-compatible storage and filesystem storage**. These URLs have a configurable expiration time to balance security and usability.
|
||||
|
||||
> **Note:** This configuration applies to **all storage types** (S3, filesystem, etc.), not just S3-compatible storage.
|
||||
|
||||
### Understanding presigned URLs
|
||||
|
||||
Presigned URLs are temporary URLs that allow direct access to files without exposing storage credentials or requiring authentication. They automatically expire after a specified time period, enhancing security by limiting access duration.
|
||||
|
||||
**How it works:**
|
||||
|
||||
- **S3 Storage:** URLs are signed by AWS/S3-compatible provider credentials
|
||||
- **Filesystem Storage:** URLs use temporary tokens that are validated by Palmr server
|
||||
|
||||
**Default behavior:**
|
||||
|
||||
- Upload URLs: 1 hour (3600 seconds)
|
||||
- Download URLs: 1 hour (3600 seconds)
|
||||
|
||||
### Configuring expiration time
|
||||
|
||||
You can customize the expiration time using the `PRESIGNED_URL_EXPIRATION` environment variable:
|
||||
|
||||
```bash
|
||||
# Set URLs to expire after 2 hours (7200 seconds)
|
||||
PRESIGNED_URL_EXPIRATION=7200
|
||||
|
||||
# Set URLs to expire after 30 minutes (1800 seconds)
|
||||
PRESIGNED_URL_EXPIRATION=1800
|
||||
|
||||
# Set URLs to expire after 6 hours (21600 seconds)
|
||||
PRESIGNED_URL_EXPIRATION=21600
|
||||
```
|
||||
|
||||
### Choosing the right expiration time
|
||||
|
||||
**Shorter expiration (15-30 minutes):**
|
||||
|
||||
- [+] Higher security
|
||||
- [+] Reduced risk of unauthorized access
|
||||
- [-] May interrupt long uploads/downloads
|
||||
- [-] Users may need to refresh links more often
|
||||
|
||||
**Longer expiration (2-6 hours):**
|
||||
|
||||
- [+] Better user experience for large files
|
||||
- [+] Fewer interruptions during transfers
|
||||
- [-] Longer exposure window if URLs are compromised
|
||||
- [-] Potential for increased storage costs if users leave downloads incomplete
|
||||
|
||||
**Recommended settings:**
|
||||
|
||||
- **High security environments:** 1800 seconds (30 minutes)
|
||||
- **Standard usage:** 3600 seconds (1 hour) - default
|
||||
- **Large file transfers:** 7200-21600 seconds (2-6 hours)
|
||||
|
||||
### Example configurations
|
||||
|
||||
**For Backblaze B2 with extended expiration:**
|
||||
|
||||
```bash
|
||||
ENABLE_S3=true
|
||||
S3_ENDPOINT=s3.us-west-002.backblazeb2.com
|
||||
S3_USE_SSL=true
|
||||
S3_ACCESS_KEY=your-key-id
|
||||
S3_SECRET_KEY=your-application-key
|
||||
S3_REGION=us-west-002
|
||||
S3_BUCKET_NAME=your-bucket-name
|
||||
S3_FORCE_PATH_STYLE=false
|
||||
PRESIGNED_URL_EXPIRATION=7200 # 2 hours for large file transfers
|
||||
```
|
||||
|
||||
**For high-security environments:**
|
||||
|
||||
```bash
|
||||
ENABLE_S3=true
|
||||
S3_ENDPOINT=s3.amazonaws.com
|
||||
S3_USE_SSL=true
|
||||
S3_ACCESS_KEY=your-access-key-id
|
||||
S3_SECRET_KEY=your-secret-access-key
|
||||
S3_REGION=us-east-1
|
||||
S3_BUCKET_NAME=your-bucket-name
|
||||
S3_FORCE_PATH_STYLE=false
|
||||
PRESIGNED_URL_EXPIRATION=1800 # 30 minutes for enhanced security
|
||||
```
|
||||
|
||||
## Configuration best practices
|
||||
|
||||
### Security considerations
|
||||
@@ -212,6 +327,19 @@ S3_FORCE_PATH_STYLE=false
|
||||
- Check firewall and network connectivity
|
||||
- Ensure SSL/TLS settings match provider requirements
|
||||
|
||||
**SSL certificate errors (self-signed certificates):**
|
||||
|
||||
If you encounter errors like `unable to verify the first certificate` or `UNABLE_TO_VERIFY_LEAF_SIGNATURE`, you're likely using self-signed SSL certificates. This is common with self-hosted MinIO or other S3-compatible services.
|
||||
|
||||
**Solution:**
|
||||
Set `S3_REJECT_UNAUTHORIZED=false` in your environment variables to allow self-signed certificates:
|
||||
|
||||
```bash
|
||||
S3_REJECT_UNAUTHORIZED=false
|
||||
```
|
||||
|
||||
**Note:** SSL certificate validation is enabled by default (`true`) for security. Set it to `false` only when using self-hosted S3 services with self-signed certificates.
|
||||
|
||||
**Authentication failures:**
|
||||
|
||||
- Confirm access key and secret key are correct
|
@@ -44,7 +44,7 @@ The central hub after login, providing an overview of recent activity, quick act
|
||||
|
||||
### Files list view
|
||||
|
||||
Comprehensive file browser displaying all uploaded files in a detailed list format with metadata, actions, and sorting options.
|
||||
Comprehensive file browser displaying all uploaded files in a detailed list format with metadata, actions, sorting options, and folder navigation.
|
||||
|
||||
<ZoomableImage
|
||||
src="/assets/v3/screenshots/files-list.png"
|
||||
@@ -53,7 +53,7 @@ Comprehensive file browser displaying all uploaded files in a detailed list form
|
||||
|
||||
### Files card view
|
||||
|
||||
Alternative file browser layout showing files as visual cards, perfect for quick browsing and visual file identification.
|
||||
Alternative file browser layout showing files as visual cards, perfect for quick browsing, visual file identification, and folder navigation.
|
||||
|
||||
<ZoomableImage
|
||||
src="/assets/v3/screenshots/files-card.png"
|
||||
@@ -73,7 +73,7 @@ File upload interface where users can drag and drop or select files to upload to
|
||||
|
||||
### Shares page
|
||||
|
||||
Management interface for all shared files and folders, showing share status, permissions, and access controls.
|
||||
Management interface for all shared files and folders, showing share status, permissions, and access controls for both individual files and folders.
|
||||
|
||||
<ZoomableImage
|
||||
src="/assets/v3/screenshots/shares.png"
|
@@ -366,13 +366,11 @@ If none of these solutions work:
|
||||
```
|
||||
|
||||
2. **Check our documentation:**
|
||||
|
||||
- [UID/GID Configuration](/docs/3.0-beta/uid-gid-configuration)
|
||||
- [Quick Start Guide](/docs/3.0-beta/quick-start)
|
||||
- [API Reference](/docs/3.0-beta/api)
|
||||
|
||||
3. **Open an issue on GitHub:**
|
||||
|
||||
- Include your `docker-compose.yaml`
|
||||
- Include relevant log output
|
||||
- Describe your system (OS, Docker version, etc.)
|
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"pages": ["3.1-beta", "2.0.0-beta"]
|
||||
"pages": ["3.2-beta", "2.0.0-beta"]
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "palmr-docs",
|
||||
"version": "3.1.6-beta",
|
||||
"version": "3.2.5-beta",
|
||||
"description": "Docs for Palmr",
|
||||
"private": true,
|
||||
"author": "Daniel Luiz Alves <daniel@kyantech.com.br>",
|
||||
@@ -13,7 +13,7 @@
|
||||
"react",
|
||||
"typescript"
|
||||
],
|
||||
"license": "BSD-2-Clause",
|
||||
"license": "Apache-2.0",
|
||||
"packageManager": "pnpm@10.6.0",
|
||||
"scripts": {
|
||||
"build": "next build",
|
||||
|
4878
apps/docs/pnpm-lock.yaml
generated
4878
apps/docs/pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -12,7 +12,6 @@ import {
|
||||
LayoutIcon,
|
||||
LockIcon,
|
||||
MousePointer,
|
||||
RadioIcon,
|
||||
RocketIcon,
|
||||
SearchIcon,
|
||||
TimerIcon,
|
||||
@@ -60,13 +59,13 @@ const images = [
|
||||
"https://res.cloudinary.com/technical-intelligence/image/upload/v1745546005/Palmr./profile_mizwvg.png",
|
||||
];
|
||||
|
||||
const docsLink = "/docs/3.1-beta";
|
||||
const docsLink = "/docs/3.2-beta";
|
||||
|
||||
function Hero() {
|
||||
return (
|
||||
<section className="relative z-[2] flex flex-col border-x border-t px-6 pt-12 pb-10 md:px-12 md:pt-16 max-md:text-center">
|
||||
<h1 className="mb-8 text-6xl font-bold">
|
||||
Palmr. <span className="text-[13px] font-light text-muted-foreground/50 font-mono">v3.1-beta</span>
|
||||
Palmr. <span className="text-[13px] font-light text-muted-foreground/50 font-mono">v3.2-beta</span>
|
||||
</h1>
|
||||
<h1 className="hidden text-4xl font-medium max-w-[600px] md:block mb-4">Modern & efficient file sharing</h1>
|
||||
<p className="mb-8 text-fd-muted-foreground md:max-w-[80%] md:text-xl">
|
||||
@@ -82,23 +81,6 @@ function Hero() {
|
||||
<Link href={docsLink}>Documentation</Link>
|
||||
</div>
|
||||
</PulsatingButton>
|
||||
<RippleButton
|
||||
onClick={() => {
|
||||
const demoId = `${Math.random().toString(36).substr(2, 9)}`;
|
||||
const token = `${Math.random().toString(36).substr(2, 12)}`;
|
||||
|
||||
sessionStorage.setItem("demo_token", token);
|
||||
sessionStorage.setItem("demo_id", demoId);
|
||||
sessionStorage.setItem("demo_expires", (Date.now() + 5 * 60 * 1000).toString());
|
||||
|
||||
window.location.href = `/demo?id=${demoId}&token=${token}`;
|
||||
}}
|
||||
>
|
||||
<div className="flex gap-2 items-center">
|
||||
<RadioIcon size={18} />
|
||||
Live Demo
|
||||
</div>
|
||||
</RippleButton>
|
||||
<RippleButton>
|
||||
<a
|
||||
href="https://github.com/kyantech/Palmr"
|
||||
@@ -312,7 +294,7 @@ function FullWidthFooter() {
|
||||
<div className="flex items-center gap-1 text-sm max-w-7xl">
|
||||
<span>Powered by</span>
|
||||
<Link
|
||||
href="http://kyantech.com.br"
|
||||
href="https://github.com/kyantech"
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
className="flex items-center hover:text-green-700 text-green-500 transition-colors font-light"
|
||||
|
@@ -9,6 +9,6 @@ export const { GET } = createFromSource(source, (page) => {
|
||||
url: page.url,
|
||||
id: page.url,
|
||||
structuredData: page.data.structuredData,
|
||||
tag: page.url.startsWith("/docs/3.1-beta") ? "v3.1-beta" : "v2.0.0-beta",
|
||||
tag: page.url.startsWith("/docs/3.2-beta") ? "v3.2-beta" : "v2.0.0-beta",
|
||||
};
|
||||
});
|
||||
|
@@ -1,225 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { useSearchParams } from "next/navigation";
|
||||
import { Palmtree } from "lucide-react";
|
||||
import { motion } from "motion/react";
|
||||
|
||||
import { BackgroundLights } from "@/components/ui/background-lights";
|
||||
import { Button } from "@/components/ui/button";
|
||||
|
||||
interface DemoStatus {
|
||||
status: "waiting" | "ready";
|
||||
url: string | null;
|
||||
}
|
||||
|
||||
interface CreateDemoResponse {
|
||||
message: string;
|
||||
url: string | null;
|
||||
}
|
||||
|
||||
function DemoClientInner() {
|
||||
const searchParams = useSearchParams();
|
||||
const demoId = searchParams.get("id");
|
||||
const token = searchParams.get("token");
|
||||
|
||||
const [status, setStatus] = useState<DemoStatus | null>(null);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const validateAccess = () => {
|
||||
const storedToken = sessionStorage.getItem("demo_token");
|
||||
const storedId = sessionStorage.getItem("demo_id");
|
||||
const expiresAt = sessionStorage.getItem("demo_expires");
|
||||
|
||||
if (!demoId || !token || !storedToken || !storedId || !expiresAt) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (token !== storedToken || demoId !== storedId || Date.now() > parseInt(expiresAt)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
if (!validateAccess()) {
|
||||
setError("Unauthorized access. Please use the Live Demo button to access this page.");
|
||||
setIsLoading(false);
|
||||
return;
|
||||
}
|
||||
|
||||
const createDemo = async () => {
|
||||
try {
|
||||
const response = await fetch("https://palmr-demo-manager.kyantech.com.br/create-demo", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
palmr_demo_instance_id: demoId,
|
||||
}),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to create demo");
|
||||
}
|
||||
|
||||
const data: CreateDemoResponse = await response.json();
|
||||
console.log("Demo creation response:", data);
|
||||
} catch (err) {
|
||||
console.error("Error creating demo:", err);
|
||||
setError("Failed to create demo. Please try again.");
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const checkStatus = async () => {
|
||||
try {
|
||||
const response = await fetch(`https://palmr-demo-manager.kyantech.com.br/status/${demoId}`);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to check demo status");
|
||||
}
|
||||
|
||||
const data: DemoStatus = await response.json();
|
||||
setStatus(data);
|
||||
|
||||
if (data.status === "ready" && data.url) {
|
||||
setIsLoading(false);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Error checking status:", err);
|
||||
setError("Failed to check demo status. Please try again.");
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
createDemo();
|
||||
|
||||
const interval = setInterval(checkStatus, 5000); // Check every 5 seconds
|
||||
|
||||
checkStatus();
|
||||
|
||||
return () => {
|
||||
clearInterval(interval);
|
||||
sessionStorage.removeItem("demo_token");
|
||||
sessionStorage.removeItem("demo_id");
|
||||
sessionStorage.removeItem("demo_expires");
|
||||
};
|
||||
}, [demoId, token]);
|
||||
|
||||
const handleGoToDemo = () => {
|
||||
if (status?.url) {
|
||||
window.open(status.url, "_blank");
|
||||
}
|
||||
window.location.href = "/";
|
||||
};
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<div className="fixed inset-0 bg-background">
|
||||
<BackgroundLights />
|
||||
<div className="relative flex flex-col items-center justify-center h-full">
|
||||
<div className="text-center space-y-6 max-w-md">
|
||||
<h1 className="text-2xl font-bold text-destructive">Error</h1>
|
||||
<p className="text-muted-foreground">{error}</p>
|
||||
<Button
|
||||
onClick={() => {
|
||||
sessionStorage.removeItem("demo_token");
|
||||
sessionStorage.removeItem("demo_id");
|
||||
sessionStorage.removeItem("demo_expires");
|
||||
window.location.href = "/";
|
||||
}}
|
||||
>
|
||||
Go Back
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="fixed inset-0 bg-background">
|
||||
<BackgroundLights />
|
||||
<div className="flex flex-col items-center gap-6 text-center h-full justify-center">
|
||||
<div className="space-y-4">
|
||||
<h1 className="text-2xl font-bold">Your demo is being generated, please wait...</h1>
|
||||
<p className="text-muted-foreground max-w-lg">
|
||||
This demo will be available for 30 minutes for testing. After that, all data will be permanently deleted
|
||||
and become inaccessible. You can test Palmr. with a 200MB storage limit.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="fixed inset-0 bg-background">
|
||||
<BackgroundLights />
|
||||
<div className="relative flex flex-col items-center justify-center h-full">
|
||||
<motion.div
|
||||
initial={{ opacity: 0, y: 20 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
transition={{ duration: 0.5 }}
|
||||
className="container mx-auto max-w-7xl px-6 flex-grow"
|
||||
>
|
||||
<section className="relative flex flex-col items-center justify-center gap-6 m-auto h-full">
|
||||
<motion.div
|
||||
initial={{ opacity: 0, y: 20 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
transition={{ duration: 0.5, delay: 0.2 }}
|
||||
className="inline-block max-w-xl text-center justify-center"
|
||||
>
|
||||
<div className="flex flex-col gap-8">
|
||||
<div className="flex flex-col gap-2">
|
||||
<motion.span
|
||||
initial={{ opacity: 0, x: -20 }}
|
||||
animate={{ opacity: 1, x: 0 }}
|
||||
transition={{ delay: 0.4, duration: 0.5 }}
|
||||
className="text-4xl lg:text-3xl font-semibold tracking-tight text-primary"
|
||||
>
|
||||
Your demo is ready!
|
||||
</motion.span>
|
||||
<motion.span
|
||||
initial={{ opacity: 0, x: 20 }}
|
||||
animate={{ opacity: 1, x: 0 }}
|
||||
transition={{ delay: 0.6, duration: 0.5 }}
|
||||
className="text-3xl leading-9 font-semibold tracking-tight"
|
||||
>
|
||||
Click the button below to test
|
||||
</motion.span>
|
||||
</div>
|
||||
</div>
|
||||
</motion.div>
|
||||
<motion.div
|
||||
initial={{ opacity: 0, y: 20 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
transition={{ duration: 0.5, delay: 0.8 }}
|
||||
className="flex flex-col items-center gap-6"
|
||||
>
|
||||
<motion.div
|
||||
initial={{ opacity: 0, scale: 0.9 }}
|
||||
animate={{ opacity: 1, scale: 1 }}
|
||||
transition={{ delay: 1.2, duration: 0.5 }}
|
||||
>
|
||||
<Button onClick={handleGoToDemo} className="flex items-center gap-2 px-8 py-4 text-lg">
|
||||
<Palmtree className="h-5 w-5" />
|
||||
Go to Palmr. Demo
|
||||
</Button>
|
||||
</motion.div>
|
||||
</motion.div>
|
||||
</section>
|
||||
</motion.div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default function DemoClient() {
|
||||
return <DemoClientInner />;
|
||||
}
|
@@ -1,13 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { Suspense } from "react";
|
||||
|
||||
import DemoClient from "./components/demo-client";
|
||||
|
||||
export default function DemoPage() {
|
||||
return (
|
||||
<Suspense>
|
||||
<DemoClient />
|
||||
</Suspense>
|
||||
);
|
||||
}
|
@@ -11,7 +11,7 @@ import { Sponsor } from "../components/sponsor";
|
||||
export default async function Page(props: { params: Promise<{ slug?: string[] }> }) {
|
||||
const params = await props.params;
|
||||
const page = source.getPage(params.slug);
|
||||
if (!page) redirect("/docs/3.1-beta");
|
||||
if (!page) redirect("/docs/3.2-beta");
|
||||
|
||||
const MDXContent = page.data.body;
|
||||
|
||||
@@ -49,7 +49,7 @@ export async function generateStaticParams() {
|
||||
export async function generateMetadata(props: { params: Promise<{ slug?: string[] }> }) {
|
||||
const params = await props.params;
|
||||
const page = source.getPage(params.slug);
|
||||
if (!page) redirect("/docs/3.1-beta");
|
||||
if (!page) redirect("/docs/3.2-beta");
|
||||
|
||||
return {
|
||||
title: page.data.title + " | Palmr. Docs",
|
||||
|
@@ -6,7 +6,7 @@ export function Footer() {
|
||||
<div className="flex items-center gap-1 text-sm ">
|
||||
<span>Powered by</span>
|
||||
<Link
|
||||
href="http://kyantech.com.br"
|
||||
href="https://github.com/kyantech"
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
className="flex items-center hover:text-green-700 text-green-500 transition-colors font-light"
|
||||
|
@@ -28,7 +28,7 @@ export default function Layout({ children }: { children: ReactNode }) {
|
||||
<RootProvider
|
||||
search={{
|
||||
options: {
|
||||
defaultTag: "3.1-beta",
|
||||
defaultTag: "3.2-beta",
|
||||
tags: [
|
||||
{
|
||||
name: "v2.0.0 Beta",
|
||||
@@ -36,7 +36,7 @@ export default function Layout({ children }: { children: ReactNode }) {
|
||||
},
|
||||
{
|
||||
name: "v3.0 Beta ✨",
|
||||
value: "3.1-beta",
|
||||
value: "3.2-beta",
|
||||
props: {
|
||||
style: {
|
||||
border: "1px solid rgba(0,165,80,0.2)",
|
||||
|
@@ -6,61 +6,61 @@ const providers = [
|
||||
{
|
||||
name: "Google",
|
||||
description: "Configure authentication using Google OAuth2 services",
|
||||
href: "/docs/3.1-beta/oidc-authentication/google",
|
||||
href: "/docs/3.2-beta/oidc-authentication/google",
|
||||
icon: <Chrome className="w-4 h-4" />,
|
||||
},
|
||||
{
|
||||
name: "Discord",
|
||||
description: "Set up Discord OAuth2 for community-based authentication",
|
||||
href: "/docs/3.1-beta/oidc-authentication/discord",
|
||||
href: "/docs/3.2-beta/oidc-authentication/discord",
|
||||
icon: <MessageSquare className="w-4 h-4" />,
|
||||
},
|
||||
{
|
||||
name: "GitHub",
|
||||
description: "Enable GitHub OAuth for developer-friendly sign-in",
|
||||
href: "/docs/3.1-beta/oidc-authentication/github",
|
||||
href: "/docs/3.2-beta/oidc-authentication/github",
|
||||
icon: <Github className="w-4 h-4" />,
|
||||
},
|
||||
{
|
||||
name: "Zitadel",
|
||||
description: "Enterprise-grade identity and access management",
|
||||
href: "/docs/3.1-beta/oidc-authentication/zitadel",
|
||||
href: "/docs/3.2-beta/oidc-authentication/zitadel",
|
||||
icon: <Shield className="w-4 h-4" />,
|
||||
},
|
||||
{
|
||||
name: "Auth0",
|
||||
description: "Flexible identity platform with extensive customization",
|
||||
href: "/docs/3.1-beta/oidc-authentication/auth0",
|
||||
href: "/docs/3.2-beta/oidc-authentication/auth0",
|
||||
icon: <Lock className="w-4 h-4" />,
|
||||
},
|
||||
{
|
||||
name: "Authentik",
|
||||
description: "Open-source identity provider with modern features",
|
||||
href: "/docs/3.1-beta/oidc-authentication/authentik",
|
||||
href: "/docs/3.2-beta/oidc-authentication/authentik",
|
||||
icon: <Key className="w-4 h-4" />,
|
||||
},
|
||||
{
|
||||
name: "Frontegg",
|
||||
description: "User management platform for B2B applications",
|
||||
href: "/docs/3.1-beta/oidc-authentication/frontegg",
|
||||
href: "/docs/3.2-beta/oidc-authentication/frontegg",
|
||||
icon: <Egg className="w-4 h-4" />,
|
||||
},
|
||||
{
|
||||
name: "Kinde Auth",
|
||||
description: "Developer-first authentication and user management",
|
||||
href: "/docs/3.1-beta/oidc-authentication/kinde-auth",
|
||||
href: "/docs/3.2-beta/oidc-authentication/kinde-auth",
|
||||
icon: <Users className="w-4 h-" />,
|
||||
},
|
||||
{
|
||||
name: "Pocket ID",
|
||||
description: "Open-source identity provider with OIDC support",
|
||||
href: "/docs/3.1-beta/oidc-authentication/pocket-id",
|
||||
href: "/docs/3.2-beta/oidc-authentication/pocket-id",
|
||||
icon: <Key className="w-4 h-4" />,
|
||||
},
|
||||
{
|
||||
name: "Other",
|
||||
description: "Configure any other OIDC-compliant identity provider",
|
||||
href: "/docs/3.1-beta/oidc-authentication/other",
|
||||
href: "/docs/3.2-beta/oidc-authentication/other",
|
||||
icon: <Settings className="w-4 h-4" />,
|
||||
},
|
||||
];
|
||||
|
@@ -1,2 +1,2 @@
|
||||
export const LATEST_VERSION_PATH = "/docs/3.1-beta";
|
||||
export const LATEST_VERSION = "v3.1-beta";
|
||||
export const LATEST_VERSION_PATH = "/docs/3.2-beta";
|
||||
export const LATEST_VERSION = "v3.2-beta";
|
||||
|
@@ -14,3 +14,5 @@ DATABASE_URL="file:./palmr.db"
|
||||
# S3_REGION=
|
||||
# S3_BUCKET_NAME=
|
||||
# S3_FORCE_PATH_STYLE=
|
||||
# S3_REJECT_UNAUTHORIZED=true # Set to false to disable strict SSL certificate validation for self-signed certificates (optional, defaults to true)
|
||||
# PRESIGNED_URL_EXPIRATION=3600 # Duration in seconds for presigned URL expiration (optional, defaults to 3600 seconds / 1 hour)
|
||||
|
1
apps/server/.gitignore
vendored
1
apps/server/.gitignore
vendored
@@ -4,3 +4,4 @@ dist/*
|
||||
uploads/*
|
||||
temp-uploads/*
|
||||
prisma/*.db
|
||||
tsconfig.tsbuildinfo
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "palmr-api",
|
||||
"version": "3.1.6-beta",
|
||||
"version": "3.2.5-beta",
|
||||
"description": "API for Palmr",
|
||||
"private": true,
|
||||
"author": "Daniel Luiz Alves <daniel@kyantech.com.br>",
|
||||
@@ -12,7 +12,7 @@
|
||||
"nodejs",
|
||||
"typescript"
|
||||
],
|
||||
"license": "BSD-2-Clause",
|
||||
"license": "Apache-2.0",
|
||||
"packageManager": "pnpm@10.6.0",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
@@ -25,7 +25,9 @@
|
||||
"format:check": "prettier . --check",
|
||||
"type-check": "npx tsc --noEmit",
|
||||
"validate": "pnpm lint && pnpm type-check",
|
||||
"db:seed": "ts-node prisma/seed.js"
|
||||
"db:seed": "ts-node prisma/seed.js",
|
||||
"cleanup:orphan-files": "tsx src/scripts/cleanup-orphan-files.ts",
|
||||
"cleanup:orphan-files:confirm": "tsx src/scripts/cleanup-orphan-files.ts --confirm"
|
||||
},
|
||||
"prisma": {
|
||||
"seed": "node prisma/seed.js"
|
||||
@@ -77,4 +79,4 @@
|
||||
"tsx": "^4.19.2",
|
||||
"typescript": "^5.7.3"
|
||||
}
|
||||
}
|
||||
}
|
4498
apps/server/pnpm-lock.yaml
generated
4498
apps/server/pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -1,287 +1,318 @@
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "sqlite"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id @default(cuid())
|
||||
firstName String
|
||||
lastName String
|
||||
username String @unique
|
||||
email String @unique
|
||||
password String?
|
||||
image String?
|
||||
isAdmin Boolean @default(false)
|
||||
isActive Boolean @default(true)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
twoFactorEnabled Boolean @default(false)
|
||||
twoFactorSecret String?
|
||||
twoFactorBackupCodes String?
|
||||
twoFactorVerified Boolean @default(false)
|
||||
|
||||
files File[]
|
||||
shares Share[]
|
||||
reverseShares ReverseShare[]
|
||||
|
||||
loginAttempts LoginAttempt?
|
||||
|
||||
passwordResets PasswordReset[]
|
||||
authProviders UserAuthProvider[]
|
||||
trustedDevices TrustedDevice[]
|
||||
|
||||
@@map("users")
|
||||
}
|
||||
|
||||
model File {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
description String?
|
||||
extension String
|
||||
size BigInt
|
||||
objectName String
|
||||
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
shares Share[] @relation("ShareFiles")
|
||||
|
||||
@@map("files")
|
||||
}
|
||||
|
||||
model Share {
|
||||
id String @id @default(cuid())
|
||||
name String?
|
||||
views Int @default(0)
|
||||
expiration DateTime?
|
||||
description String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
creatorId String?
|
||||
creator User? @relation(fields: [creatorId], references: [id], onDelete: SetNull)
|
||||
|
||||
securityId String @unique
|
||||
security ShareSecurity @relation(fields: [securityId], references: [id])
|
||||
|
||||
files File[] @relation("ShareFiles")
|
||||
recipients ShareRecipient[]
|
||||
|
||||
alias ShareAlias?
|
||||
|
||||
@@map("shares")
|
||||
}
|
||||
|
||||
model ShareSecurity {
|
||||
id String @id @default(cuid())
|
||||
password String?
|
||||
maxViews Int?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
share Share?
|
||||
|
||||
@@map("share_security")
|
||||
}
|
||||
|
||||
model ShareRecipient {
|
||||
id String @id @default(cuid())
|
||||
email String
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
shareId String
|
||||
share Share @relation(fields: [shareId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("share_recipients")
|
||||
}
|
||||
|
||||
model AppConfig {
|
||||
id String @id @default(cuid())
|
||||
key String @unique
|
||||
value String
|
||||
type String
|
||||
group String
|
||||
isSystem Boolean @default(true)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@map("app_configs")
|
||||
}
|
||||
|
||||
model LoginAttempt {
|
||||
id String @id @default(cuid())
|
||||
userId String @unique
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
attempts Int @default(1)
|
||||
lastAttempt DateTime @default(now())
|
||||
|
||||
@@map("login_attempts")
|
||||
}
|
||||
|
||||
model PasswordReset {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
token String @unique
|
||||
expiresAt DateTime
|
||||
used Boolean @default(false)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@map("password_resets")
|
||||
}
|
||||
|
||||
model ShareAlias {
|
||||
id String @id @default(cuid())
|
||||
alias String @unique
|
||||
shareId String @unique
|
||||
share Share @relation(fields: [shareId], references: [id], onDelete: Cascade)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@map("share_aliases")
|
||||
}
|
||||
|
||||
model AuthProvider {
|
||||
id String @id @default(cuid())
|
||||
name String @unique
|
||||
displayName String
|
||||
type String
|
||||
icon String?
|
||||
enabled Boolean @default(false)
|
||||
|
||||
issuerUrl String?
|
||||
clientId String?
|
||||
clientSecret String?
|
||||
redirectUri String?
|
||||
scope String? @default("openid profile email")
|
||||
|
||||
authorizationEndpoint String?
|
||||
tokenEndpoint String?
|
||||
userInfoEndpoint String?
|
||||
|
||||
metadata String?
|
||||
|
||||
autoRegister Boolean @default(true)
|
||||
adminEmailDomains String?
|
||||
|
||||
sortOrder Int @default(0)
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
userAuthProviders UserAuthProvider[]
|
||||
|
||||
@@map("auth_providers")
|
||||
}
|
||||
|
||||
model UserAuthProvider {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
providerId String
|
||||
authProvider AuthProvider @relation(fields: [providerId], references: [id], onDelete: Cascade)
|
||||
|
||||
provider String?
|
||||
|
||||
externalId String
|
||||
metadata String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@unique([userId, providerId])
|
||||
@@unique([providerId, externalId])
|
||||
@@map("user_auth_providers")
|
||||
}
|
||||
|
||||
model ReverseShare {
|
||||
id String @id @default(cuid())
|
||||
name String?
|
||||
description String?
|
||||
expiration DateTime?
|
||||
maxFiles Int?
|
||||
maxFileSize BigInt?
|
||||
allowedFileTypes String?
|
||||
password String?
|
||||
pageLayout PageLayout @default(DEFAULT)
|
||||
isActive Boolean @default(true)
|
||||
nameFieldRequired FieldRequirement @default(OPTIONAL)
|
||||
emailFieldRequired FieldRequirement @default(OPTIONAL)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
creatorId String
|
||||
creator User @relation(fields: [creatorId], references: [id], onDelete: Cascade)
|
||||
|
||||
files ReverseShareFile[]
|
||||
alias ReverseShareAlias?
|
||||
|
||||
@@map("reverse_shares")
|
||||
}
|
||||
|
||||
model ReverseShareFile {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
description String?
|
||||
extension String
|
||||
size BigInt
|
||||
objectName String
|
||||
uploaderEmail String?
|
||||
uploaderName String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
reverseShareId String
|
||||
reverseShare ReverseShare @relation(fields: [reverseShareId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("reverse_share_files")
|
||||
}
|
||||
|
||||
model ReverseShareAlias {
|
||||
id String @id @default(cuid())
|
||||
alias String @unique
|
||||
reverseShareId String @unique
|
||||
reverseShare ReverseShare @relation(fields: [reverseShareId], references: [id], onDelete: Cascade)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@map("reverse_share_aliases")
|
||||
}
|
||||
|
||||
enum FieldRequirement {
|
||||
HIDDEN
|
||||
OPTIONAL
|
||||
REQUIRED
|
||||
}
|
||||
|
||||
enum PageLayout {
|
||||
DEFAULT
|
||||
WETRANSFER
|
||||
}
|
||||
|
||||
model TrustedDevice {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
deviceHash String @unique
|
||||
deviceName String?
|
||||
userAgent String?
|
||||
ipAddress String?
|
||||
lastUsedAt DateTime @default(now())
|
||||
expiresAt DateTime
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@map("trusted_devices")
|
||||
}
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "sqlite"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id @default(cuid())
|
||||
firstName String
|
||||
lastName String
|
||||
username String @unique
|
||||
email String @unique
|
||||
password String?
|
||||
image String?
|
||||
isAdmin Boolean @default(false)
|
||||
isActive Boolean @default(true)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
twoFactorEnabled Boolean @default(false)
|
||||
twoFactorSecret String?
|
||||
twoFactorBackupCodes String?
|
||||
twoFactorVerified Boolean @default(false)
|
||||
|
||||
files File[]
|
||||
folders Folder[]
|
||||
shares Share[]
|
||||
reverseShares ReverseShare[]
|
||||
|
||||
loginAttempts LoginAttempt?
|
||||
|
||||
passwordResets PasswordReset[]
|
||||
authProviders UserAuthProvider[]
|
||||
trustedDevices TrustedDevice[]
|
||||
|
||||
@@map("users")
|
||||
}
|
||||
|
||||
model File {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
description String?
|
||||
extension String
|
||||
size BigInt
|
||||
objectName String
|
||||
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
folderId String?
|
||||
folder Folder? @relation(fields: [folderId], references: [id], onDelete: Cascade)
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
shares Share[] @relation("ShareFiles")
|
||||
|
||||
@@index([folderId])
|
||||
@@map("files")
|
||||
}
|
||||
|
||||
model Share {
|
||||
id String @id @default(cuid())
|
||||
name String?
|
||||
views Int @default(0)
|
||||
expiration DateTime?
|
||||
description String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
creatorId String?
|
||||
creator User? @relation(fields: [creatorId], references: [id], onDelete: SetNull)
|
||||
|
||||
securityId String @unique
|
||||
security ShareSecurity @relation(fields: [securityId], references: [id])
|
||||
|
||||
files File[] @relation("ShareFiles")
|
||||
folders Folder[] @relation("ShareFolders")
|
||||
recipients ShareRecipient[]
|
||||
|
||||
alias ShareAlias?
|
||||
|
||||
@@map("shares")
|
||||
}
|
||||
|
||||
model ShareSecurity {
|
||||
id String @id @default(cuid())
|
||||
password String?
|
||||
maxViews Int?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
share Share?
|
||||
|
||||
@@map("share_security")
|
||||
}
|
||||
|
||||
model ShareRecipient {
|
||||
id String @id @default(cuid())
|
||||
email String
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
shareId String
|
||||
share Share @relation(fields: [shareId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("share_recipients")
|
||||
}
|
||||
|
||||
model AppConfig {
|
||||
id String @id @default(cuid())
|
||||
key String @unique
|
||||
value String
|
||||
type String
|
||||
group String
|
||||
isSystem Boolean @default(true)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@map("app_configs")
|
||||
}
|
||||
|
||||
model LoginAttempt {
|
||||
id String @id @default(cuid())
|
||||
userId String @unique
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
attempts Int @default(1)
|
||||
lastAttempt DateTime @default(now())
|
||||
|
||||
@@map("login_attempts")
|
||||
}
|
||||
|
||||
model PasswordReset {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
token String @unique
|
||||
expiresAt DateTime
|
||||
used Boolean @default(false)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@map("password_resets")
|
||||
}
|
||||
|
||||
model ShareAlias {
|
||||
id String @id @default(cuid())
|
||||
alias String @unique
|
||||
shareId String @unique
|
||||
share Share @relation(fields: [shareId], references: [id], onDelete: Cascade)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@map("share_aliases")
|
||||
}
|
||||
|
||||
model AuthProvider {
|
||||
id String @id @default(cuid())
|
||||
name String @unique
|
||||
displayName String
|
||||
type String
|
||||
icon String?
|
||||
enabled Boolean @default(false)
|
||||
|
||||
issuerUrl String?
|
||||
clientId String?
|
||||
clientSecret String?
|
||||
redirectUri String?
|
||||
scope String? @default("openid profile email")
|
||||
|
||||
authorizationEndpoint String?
|
||||
tokenEndpoint String?
|
||||
userInfoEndpoint String?
|
||||
|
||||
metadata String?
|
||||
|
||||
autoRegister Boolean @default(true)
|
||||
adminEmailDomains String?
|
||||
|
||||
sortOrder Int @default(0)
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
userAuthProviders UserAuthProvider[]
|
||||
|
||||
@@map("auth_providers")
|
||||
}
|
||||
|
||||
model UserAuthProvider {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
providerId String
|
||||
authProvider AuthProvider @relation(fields: [providerId], references: [id], onDelete: Cascade)
|
||||
|
||||
provider String?
|
||||
|
||||
externalId String
|
||||
metadata String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@unique([userId, providerId])
|
||||
@@unique([providerId, externalId])
|
||||
@@map("user_auth_providers")
|
||||
}
|
||||
|
||||
model ReverseShare {
|
||||
id String @id @default(cuid())
|
||||
name String?
|
||||
description String?
|
||||
expiration DateTime?
|
||||
maxFiles Int?
|
||||
maxFileSize BigInt?
|
||||
allowedFileTypes String?
|
||||
password String?
|
||||
pageLayout PageLayout @default(DEFAULT)
|
||||
isActive Boolean @default(true)
|
||||
nameFieldRequired FieldRequirement @default(OPTIONAL)
|
||||
emailFieldRequired FieldRequirement @default(OPTIONAL)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
creatorId String
|
||||
creator User @relation(fields: [creatorId], references: [id], onDelete: Cascade)
|
||||
|
||||
files ReverseShareFile[]
|
||||
alias ReverseShareAlias?
|
||||
|
||||
@@map("reverse_shares")
|
||||
}
|
||||
|
||||
model ReverseShareFile {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
description String?
|
||||
extension String
|
||||
size BigInt
|
||||
objectName String
|
||||
uploaderEmail String?
|
||||
uploaderName String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
reverseShareId String
|
||||
reverseShare ReverseShare @relation(fields: [reverseShareId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("reverse_share_files")
|
||||
}
|
||||
|
||||
model ReverseShareAlias {
|
||||
id String @id @default(cuid())
|
||||
alias String @unique
|
||||
reverseShareId String @unique
|
||||
reverseShare ReverseShare @relation(fields: [reverseShareId], references: [id], onDelete: Cascade)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@map("reverse_share_aliases")
|
||||
}
|
||||
|
||||
enum FieldRequirement {
|
||||
HIDDEN
|
||||
OPTIONAL
|
||||
REQUIRED
|
||||
}
|
||||
|
||||
enum PageLayout {
|
||||
DEFAULT
|
||||
WETRANSFER
|
||||
}
|
||||
|
||||
model TrustedDevice {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
deviceHash String @unique
|
||||
deviceName String?
|
||||
userAgent String?
|
||||
ipAddress String?
|
||||
lastUsedAt DateTime @default(now())
|
||||
expiresAt DateTime
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@map("trusted_devices")
|
||||
}
|
||||
|
||||
model Folder {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
description String?
|
||||
objectName String
|
||||
|
||||
parentId String?
|
||||
parent Folder? @relation("FolderHierarchy", fields: [parentId], references: [id], onDelete: Cascade)
|
||||
children Folder[] @relation("FolderHierarchy")
|
||||
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
files File[]
|
||||
|
||||
shares Share[] @relation("ShareFolders")
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@index([userId])
|
||||
@@index([parentId])
|
||||
@@map("folders")
|
||||
}
|
||||
|
@@ -17,6 +17,12 @@ const defaultConfigs = [
|
||||
type: "boolean",
|
||||
group: "general",
|
||||
},
|
||||
{
|
||||
key: "hideVersion",
|
||||
value: "false",
|
||||
type: "boolean",
|
||||
group: "general",
|
||||
},
|
||||
{
|
||||
key: "appDescription",
|
||||
value: "Secure and simple file sharing - Your personal cloud",
|
||||
|
@@ -6,7 +6,7 @@
|
||||
echo "🔐 Palmr Password Reset Tool"
|
||||
echo "============================="
|
||||
|
||||
# Check if we're in the right directory
|
||||
# Check if we're in the right directory and set DATABASE_URL
|
||||
if [ ! -f "package.json" ]; then
|
||||
echo "❌ Error: This script must be run from the server directory (/app/server)"
|
||||
echo " Current directory: $(pwd)"
|
||||
@@ -14,18 +14,26 @@ if [ ! -f "package.json" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Set DATABASE_URL if not already set
|
||||
if [ -z "$DATABASE_URL" ]; then
|
||||
export DATABASE_URL="file:/app/server/prisma/palmr.db"
|
||||
fi
|
||||
|
||||
# Ensure database directory exists
|
||||
mkdir -p /app/server/prisma
|
||||
|
||||
# Function to check if tsx is available
|
||||
check_tsx() {
|
||||
# Check if tsx binary exists in node_modules
|
||||
if [ -f "node_modules/.bin/tsx" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
|
||||
# Fallback: try npx
|
||||
if npx tsx --version >/dev/null 2>&1; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
@@ -39,7 +47,7 @@ install_tsx_only() {
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
return $?
|
||||
}
|
||||
|
||||
@@ -62,7 +70,7 @@ ensure_prisma() {
|
||||
if [ -d "node_modules/@prisma/client" ] && [ -f "node_modules/@prisma/client/index.js" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
|
||||
echo "📦 Generating Prisma client..."
|
||||
if npx prisma generate --silent >/dev/null 2>&1; then
|
||||
echo "✅ Prisma client ready"
|
||||
@@ -81,14 +89,14 @@ if check_tsx; then
|
||||
echo "✅ tsx is ready"
|
||||
else
|
||||
echo "📦 tsx not found, installing..."
|
||||
|
||||
|
||||
# Try quick tsx-only install first
|
||||
if install_tsx_only && check_tsx; then
|
||||
echo "✅ tsx installed successfully"
|
||||
else
|
||||
echo "⚠️ Quick install failed, installing all dependencies..."
|
||||
install_all_deps
|
||||
|
||||
|
||||
# Final check
|
||||
if ! check_tsx; then
|
||||
echo "❌ Error: tsx is still not available after full installation"
|
||||
@@ -119,4 +127,4 @@ if [ -f "node_modules/.bin/tsx" ]; then
|
||||
node_modules/.bin/tsx src/scripts/reset-password.ts "$@"
|
||||
else
|
||||
npx tsx src/scripts/reset-password.ts "$@"
|
||||
fi
|
||||
fi
|
@@ -1,4 +1,5 @@
|
||||
import crypto from "node:crypto";
|
||||
import * as http from "node:http";
|
||||
import fastifyCookie from "@fastify/cookie";
|
||||
import { fastifyCors } from "@fastify/cors";
|
||||
import fastifyJwt from "@fastify/jwt";
|
||||
@@ -31,6 +32,31 @@ export async function buildApp() {
|
||||
keepAliveTimeout: envTimeoutOverrides.keepAliveTimeout,
|
||||
requestTimeout: envTimeoutOverrides.requestTimeout,
|
||||
trustProxy: true,
|
||||
maxParamLength: 500,
|
||||
onProtoPoisoning: "ignore",
|
||||
onConstructorPoisoning: "ignore",
|
||||
ignoreTrailingSlash: true,
|
||||
serverFactory: (handler: (req: any, res: any) => void) => {
|
||||
const server = http.createServer((req: http.IncomingMessage, res: http.ServerResponse) => {
|
||||
res.setTimeout(0);
|
||||
req.setTimeout(0);
|
||||
|
||||
req.on("close", () => {
|
||||
if (typeof global !== "undefined" && global.gc) {
|
||||
setImmediate(() => global.gc!());
|
||||
}
|
||||
});
|
||||
|
||||
handler(req, res);
|
||||
});
|
||||
|
||||
server.maxHeadersCount = 0;
|
||||
server.timeout = 0;
|
||||
server.keepAliveTimeout = envTimeoutOverrides.keepAliveTimeout;
|
||||
server.headersTimeout = envTimeoutOverrides.keepAliveTimeout + 1000;
|
||||
|
||||
return server;
|
||||
},
|
||||
}).withTypeProvider<ZodTypeProvider>();
|
||||
|
||||
app.setValidatorCompiler(validatorCompiler);
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import process from "node:process";
|
||||
import { S3Client } from "@aws-sdk/client-s3";
|
||||
|
||||
import { env } from "../env";
|
||||
@@ -14,6 +15,14 @@ export const storageConfig: StorageConfig = {
|
||||
forcePathStyle: env.S3_FORCE_PATH_STYLE === "true",
|
||||
};
|
||||
|
||||
if (storageConfig.useSSL && env.S3_REJECT_UNAUTHORIZED === "false") {
|
||||
const originalRejectUnauthorized = process.env.NODE_TLS_REJECT_UNAUTHORIZED;
|
||||
if (!originalRejectUnauthorized) {
|
||||
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
|
||||
(global as any).PALMR_ORIGINAL_TLS_SETTING = originalRejectUnauthorized;
|
||||
}
|
||||
}
|
||||
|
||||
export const s3Client =
|
||||
env.ENABLE_S3 === "true"
|
||||
? new S3Client({
|
||||
|
@@ -18,6 +18,7 @@ export function registerSwagger(app: any) {
|
||||
{ name: "Auth Providers", description: "External authentication providers management" },
|
||||
{ name: "User", description: "User management endpoints" },
|
||||
{ name: "File", description: "File management endpoints" },
|
||||
{ name: "Folder", description: "Folder management endpoints" },
|
||||
{ name: "Share", description: "File sharing endpoints" },
|
||||
{ name: "Storage", description: "Storage management endpoints" },
|
||||
{ name: "App", description: "Application configuration endpoints" },
|
||||
|
@@ -12,9 +12,28 @@ const envSchema = z.object({
|
||||
S3_REGION: z.string().optional(),
|
||||
S3_BUCKET_NAME: z.string().optional(),
|
||||
S3_FORCE_PATH_STYLE: z.union([z.literal("true"), z.literal("false")]).default("false"),
|
||||
S3_REJECT_UNAUTHORIZED: z.union([z.literal("true"), z.literal("false")]).default("true"),
|
||||
PRESIGNED_URL_EXPIRATION: z.string().optional().default("3600"),
|
||||
SECURE_SITE: z.union([z.literal("true"), z.literal("false")]).default("false"),
|
||||
DATABASE_URL: z.string().optional().default("file:/app/server/prisma/palmr.db"),
|
||||
DEMO_MODE: z.union([z.literal("true"), z.literal("false")]).default("false"),
|
||||
DOWNLOAD_MAX_CONCURRENT: z
|
||||
.string()
|
||||
.optional()
|
||||
.transform((val) => (val ? parseInt(val, 10) : undefined)),
|
||||
DOWNLOAD_MEMORY_THRESHOLD_MB: z
|
||||
.string()
|
||||
.optional()
|
||||
.transform((val) => (val ? parseInt(val, 10) : undefined)),
|
||||
DOWNLOAD_QUEUE_SIZE: z
|
||||
.string()
|
||||
.optional()
|
||||
.transform((val) => (val ? parseInt(val, 10) : undefined)),
|
||||
DOWNLOAD_AUTO_SCALE: z.union([z.literal("true"), z.literal("false")]).default("true"),
|
||||
DOWNLOAD_MIN_FILE_SIZE_GB: z
|
||||
.string()
|
||||
.optional()
|
||||
.transform((val) => (val ? parseFloat(val) : undefined)),
|
||||
CUSTOM_PATH: z.string().optional(),
|
||||
});
|
||||
|
||||
export const env = envSchema.parse(process.env);
|
||||
|
@@ -9,7 +9,7 @@ export class AppController {
|
||||
private logoService = new LogoService();
|
||||
private emailService = new EmailService();
|
||||
|
||||
async getAppInfo(request: FastifyRequest, reply: FastifyReply) {
|
||||
async getAppInfo(_request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
const appInfo = await this.appService.getAppInfo();
|
||||
return reply.send(appInfo);
|
||||
@@ -18,7 +18,7 @@ export class AppController {
|
||||
}
|
||||
}
|
||||
|
||||
async getSystemInfo(request: FastifyRequest, reply: FastifyReply) {
|
||||
async getSystemInfo(_request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
const systemInfo = await this.appService.getSystemInfo();
|
||||
return reply.send(systemInfo);
|
||||
@@ -27,7 +27,7 @@ export class AppController {
|
||||
}
|
||||
}
|
||||
|
||||
async getAllConfigs(request: FastifyRequest, reply: FastifyReply) {
|
||||
async getAllConfigs(_request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
const configs = await this.appService.getAllConfigs();
|
||||
return reply.send({ configs });
|
||||
@@ -36,6 +36,15 @@ export class AppController {
|
||||
}
|
||||
}
|
||||
|
||||
async getPublicConfigs(_request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
const configs = await this.appService.getPublicConfigs();
|
||||
return reply.send({ configs });
|
||||
} catch (error: any) {
|
||||
return reply.status(400).send({ error: error.message });
|
||||
}
|
||||
}
|
||||
|
||||
async updateConfig(request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
const { key } = request.params as { key: string };
|
||||
@@ -90,9 +99,8 @@ export class AppController {
|
||||
return reply.status(400).send({ error: "Only images are allowed" });
|
||||
}
|
||||
|
||||
// Logo files should be small (max 5MB), so we can safely use streaming to buffer
|
||||
const chunks: Buffer[] = [];
|
||||
const maxLogoSize = 5 * 1024 * 1024; // 5MB
|
||||
const maxLogoSize = 5 * 1024 * 1024;
|
||||
let totalSize = 0;
|
||||
|
||||
for await (const chunk of file.file) {
|
||||
@@ -114,7 +122,7 @@ export class AppController {
|
||||
}
|
||||
}
|
||||
|
||||
async removeLogo(request: FastifyRequest, reply: FastifyReply) {
|
||||
async removeLogo(_request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
await this.logoService.deleteLogo();
|
||||
return reply.send({ message: "Logo removed successfully" });
|
||||
|
@@ -102,15 +102,34 @@ export async function appRoutes(app: FastifyInstance) {
|
||||
appController.updateConfig.bind(appController)
|
||||
);
|
||||
|
||||
app.get(
|
||||
"/app/configs/public",
|
||||
{
|
||||
schema: {
|
||||
tags: ["App"],
|
||||
operationId: "getPublicConfigs",
|
||||
summary: "List public configurations",
|
||||
description: "List public configurations (excludes sensitive data like SMTP credentials)",
|
||||
response: {
|
||||
200: z.object({
|
||||
configs: z.array(ConfigResponseSchema),
|
||||
}),
|
||||
400: z.object({ error: z.string().describe("Error message") }),
|
||||
},
|
||||
},
|
||||
},
|
||||
appController.getPublicConfigs.bind(appController)
|
||||
);
|
||||
|
||||
app.get(
|
||||
"/app/configs",
|
||||
{
|
||||
// preValidation: adminPreValidation,
|
||||
preValidation: adminPreValidation,
|
||||
schema: {
|
||||
tags: ["App"],
|
||||
operationId: "getAllConfigs",
|
||||
summary: "List all configurations",
|
||||
description: "List all configurations (admin only)",
|
||||
description: "List all configurations including sensitive data (admin only)",
|
||||
response: {
|
||||
200: z.object({
|
||||
configs: z.array(ConfigResponseSchema),
|
||||
|
@@ -41,6 +41,30 @@ export class AppService {
|
||||
});
|
||||
}
|
||||
|
||||
async getPublicConfigs() {
|
||||
const sensitiveKeys = [
|
||||
"smtpHost",
|
||||
"smtpPort",
|
||||
"smtpUser",
|
||||
"smtpPass",
|
||||
"smtpSecure",
|
||||
"smtpNoAuth",
|
||||
"smtpTrustSelfSigned",
|
||||
"jwtSecret",
|
||||
];
|
||||
|
||||
return prisma.appConfig.findMany({
|
||||
where: {
|
||||
key: {
|
||||
notIn: sensitiveKeys,
|
||||
},
|
||||
},
|
||||
orderBy: {
|
||||
group: "asc",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async updateConfig(key: string, value: string) {
|
||||
if (key === "jwtSecret") {
|
||||
throw new Error("JWT Secret cannot be updated through this endpoint");
|
||||
|
@@ -617,6 +617,11 @@ export class AuthProvidersService {
|
||||
return await this.linkProviderToExistingUser(existingUser, provider.id, String(externalId), userInfo);
|
||||
}
|
||||
|
||||
// Check if auto-registration is disabled
|
||||
if (provider.autoRegister === false) {
|
||||
throw new Error(`User registration via ${provider.displayName || provider.name} is disabled`);
|
||||
}
|
||||
|
||||
return await this.createNewUserWithProvider(userInfo, provider.id, String(externalId));
|
||||
}
|
||||
|
||||
|
@@ -113,14 +113,21 @@ export class AuthController {
|
||||
|
||||
async getCurrentUser(request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
const userId = (request as any).user?.userId;
|
||||
let userId: string | null = null;
|
||||
try {
|
||||
await request.jwtVerify();
|
||||
userId = (request as any).user?.userId;
|
||||
} catch (err) {
|
||||
return reply.send({ user: null });
|
||||
}
|
||||
|
||||
if (!userId) {
|
||||
return reply.status(401).send({ error: "Unauthorized: a valid token is required to access this resource." });
|
||||
return reply.send({ user: null });
|
||||
}
|
||||
|
||||
const user = await this.authService.getUserById(userId);
|
||||
if (!user) {
|
||||
return reply.status(404).send({ error: "User not found" });
|
||||
return reply.send({ user: null });
|
||||
}
|
||||
|
||||
return reply.send({ user });
|
||||
|
@@ -153,33 +153,29 @@ export async function authRoutes(app: FastifyInstance) {
|
||||
tags: ["Authentication"],
|
||||
operationId: "getCurrentUser",
|
||||
summary: "Get Current User",
|
||||
description: "Returns the current authenticated user's information",
|
||||
description: "Returns the current authenticated user's information or null if not authenticated",
|
||||
response: {
|
||||
200: z.object({
|
||||
user: z.object({
|
||||
id: z.string().describe("User ID"),
|
||||
firstName: z.string().describe("User first name"),
|
||||
lastName: z.string().describe("User last name"),
|
||||
username: z.string().describe("User username"),
|
||||
email: z.string().email().describe("User email"),
|
||||
image: z.string().nullable().describe("User profile image URL"),
|
||||
isAdmin: z.boolean().describe("User is admin"),
|
||||
isActive: z.boolean().describe("User is active"),
|
||||
createdAt: z.date().describe("User creation date"),
|
||||
updatedAt: z.date().describe("User last update date"),
|
||||
200: z.union([
|
||||
z.object({
|
||||
user: z.object({
|
||||
id: z.string().describe("User ID"),
|
||||
firstName: z.string().describe("User first name"),
|
||||
lastName: z.string().describe("User last name"),
|
||||
username: z.string().describe("User username"),
|
||||
email: z.string().email().describe("User email"),
|
||||
image: z.string().nullable().describe("User profile image URL"),
|
||||
isAdmin: z.boolean().describe("User is admin"),
|
||||
isActive: z.boolean().describe("User is active"),
|
||||
createdAt: z.date().describe("User creation date"),
|
||||
updatedAt: z.date().describe("User last update date"),
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
401: z.object({ error: z.string().describe("Error message") }),
|
||||
z.object({
|
||||
user: z.null().describe("No user when not authenticated"),
|
||||
}),
|
||||
]),
|
||||
},
|
||||
},
|
||||
preValidation: async (request: FastifyRequest, reply: FastifyReply) => {
|
||||
try {
|
||||
await request.jwtVerify();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
reply.status(401).send({ error: "Unauthorized: a valid token is required to access this resource." });
|
||||
}
|
||||
},
|
||||
},
|
||||
authController.getCurrentUser.bind(authController)
|
||||
);
|
||||
|
@@ -1,9 +1,28 @@
|
||||
import * as fs from "fs";
|
||||
import bcrypt from "bcryptjs";
|
||||
import { FastifyReply, FastifyRequest } from "fastify";
|
||||
|
||||
import { env } from "../../env";
|
||||
import { prisma } from "../../shared/prisma";
|
||||
import {
|
||||
generateUniqueFileName,
|
||||
generateUniqueFileNameForRename,
|
||||
parseFileName,
|
||||
} from "../../utils/file-name-generator";
|
||||
import { getContentType } from "../../utils/mime-types";
|
||||
import { ConfigService } from "../config/service";
|
||||
import { CheckFileInput, CheckFileSchema, RegisterFileInput, RegisterFileSchema, UpdateFileSchema } from "./dto";
|
||||
import {
|
||||
CheckFileInput,
|
||||
CheckFileSchema,
|
||||
ListFilesInput,
|
||||
ListFilesSchema,
|
||||
MoveFileInput,
|
||||
MoveFileSchema,
|
||||
RegisterFileInput,
|
||||
RegisterFileSchema,
|
||||
UpdateFileInput,
|
||||
UpdateFileSchema,
|
||||
} from "./dto";
|
||||
import { FileService } from "./service";
|
||||
|
||||
export class FileController {
|
||||
@@ -28,7 +47,7 @@ export class FileController {
|
||||
}
|
||||
|
||||
const objectName = `${userId}/${Date.now()}-${filename}.${extension}`;
|
||||
const expires = 3600;
|
||||
const expires = parseInt(env.PRESIGNED_URL_EXPIRATION);
|
||||
|
||||
const url = await this.fileService.getPresignedPutUrl(objectName, expires);
|
||||
return reply.send({ url, objectName });
|
||||
@@ -56,17 +75,7 @@ export class FileController {
|
||||
});
|
||||
}
|
||||
|
||||
// Check if DEMO_MODE is enabled
|
||||
const isDemoMode = env.DEMO_MODE === "true";
|
||||
|
||||
let maxTotalStorage: bigint;
|
||||
if (isDemoMode) {
|
||||
// In demo mode, limit all users to 200MB
|
||||
maxTotalStorage = BigInt(200 * 1024 * 1024); // 200MB in bytes
|
||||
} else {
|
||||
// Normal behavior - use maxTotalStoragePerUser configuration
|
||||
maxTotalStorage = BigInt(await this.configService.getValue("maxTotalStoragePerUser"));
|
||||
}
|
||||
const maxTotalStorage = BigInt(await this.configService.getValue("maxTotalStoragePerUser"));
|
||||
|
||||
const userFiles = await prisma.file.findMany({
|
||||
where: { userId },
|
||||
@@ -82,14 +91,28 @@ export class FileController {
|
||||
});
|
||||
}
|
||||
|
||||
if (input.folderId) {
|
||||
const folder = await prisma.folder.findFirst({
|
||||
where: { id: input.folderId, userId },
|
||||
});
|
||||
if (!folder) {
|
||||
return reply.status(400).send({ error: "Folder not found or access denied." });
|
||||
}
|
||||
}
|
||||
|
||||
// Parse the filename and generate a unique name if there's a duplicate
|
||||
const { baseName, extension } = parseFileName(input.name);
|
||||
const uniqueName = await generateUniqueFileName(baseName, extension, userId, input.folderId);
|
||||
|
||||
const fileRecord = await prisma.file.create({
|
||||
data: {
|
||||
name: input.name,
|
||||
name: uniqueName,
|
||||
description: input.description,
|
||||
extension: input.extension,
|
||||
size: BigInt(input.size),
|
||||
objectName: input.objectName,
|
||||
userId,
|
||||
folderId: input.folderId,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -101,6 +124,7 @@ export class FileController {
|
||||
size: fileRecord.size.toString(),
|
||||
objectName: fileRecord.objectName,
|
||||
userId: fileRecord.userId,
|
||||
folderId: fileRecord.folderId,
|
||||
createdAt: fileRecord.createdAt,
|
||||
updatedAt: fileRecord.updatedAt,
|
||||
};
|
||||
@@ -138,17 +162,7 @@ export class FileController {
|
||||
});
|
||||
}
|
||||
|
||||
// Check if DEMO_MODE is enabled
|
||||
const isDemoMode = env.DEMO_MODE === "true";
|
||||
|
||||
let maxTotalStorage: bigint;
|
||||
if (isDemoMode) {
|
||||
// In demo mode, limit all users to 200MB
|
||||
maxTotalStorage = BigInt(200 * 1024 * 1024); // 200MB in bytes
|
||||
} else {
|
||||
// Normal behavior - use maxTotalStoragePerUser configuration
|
||||
maxTotalStorage = BigInt(await this.configService.getValue("maxTotalStoragePerUser"));
|
||||
}
|
||||
const maxTotalStorage = BigInt(await this.configService.getValue("maxTotalStoragePerUser"));
|
||||
|
||||
const userFiles = await prisma.file.findMany({
|
||||
where: { userId },
|
||||
@@ -166,9 +180,20 @@ export class FileController {
|
||||
});
|
||||
}
|
||||
|
||||
return reply.status(201).send({
|
||||
// Check for duplicate filename and provide the suggested unique name
|
||||
const { baseName, extension } = parseFileName(input.name);
|
||||
const uniqueName = await generateUniqueFileName(baseName, extension, userId, input.folderId);
|
||||
|
||||
// Include suggestedName in response if the name was changed
|
||||
const response: any = {
|
||||
message: "File checks succeeded.",
|
||||
});
|
||||
};
|
||||
|
||||
if (uniqueName !== input.name) {
|
||||
response.suggestedName = uniqueName;
|
||||
}
|
||||
|
||||
return reply.status(201).send(response);
|
||||
} catch (error: any) {
|
||||
console.error("Error in checkFile:", error);
|
||||
return reply.status(400).send({ error: error.message });
|
||||
@@ -177,10 +202,10 @@ export class FileController {
|
||||
|
||||
async getDownloadUrl(request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
const { objectName: encodedObjectName } = request.params as {
|
||||
const { objectName, password } = request.query as {
|
||||
objectName: string;
|
||||
password?: string;
|
||||
};
|
||||
const objectName = decodeURIComponent(encodedObjectName);
|
||||
|
||||
if (!objectName) {
|
||||
return reply.status(400).send({ error: "The 'objectName' parameter is required." });
|
||||
@@ -191,8 +216,54 @@ export class FileController {
|
||||
if (!fileRecord) {
|
||||
return reply.status(404).send({ error: "File not found." });
|
||||
}
|
||||
|
||||
let hasAccess = false;
|
||||
|
||||
// Don't log raw passwords. Log only whether a password was provided (for debugging access flow).
|
||||
console.log(`Requested file access for object="${objectName}" passwordProvided=${password ? true : false}`);
|
||||
|
||||
const shares = await prisma.share.findMany({
|
||||
where: {
|
||||
files: {
|
||||
some: {
|
||||
id: fileRecord.id,
|
||||
},
|
||||
},
|
||||
},
|
||||
include: {
|
||||
security: true,
|
||||
},
|
||||
});
|
||||
|
||||
for (const share of shares) {
|
||||
if (!share.security.password) {
|
||||
hasAccess = true;
|
||||
break;
|
||||
} else if (password) {
|
||||
const isPasswordValid = await bcrypt.compare(password, share.security.password);
|
||||
if (isPasswordValid) {
|
||||
hasAccess = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasAccess) {
|
||||
try {
|
||||
await request.jwtVerify();
|
||||
const userId = (request as any).user?.userId;
|
||||
if (userId && fileRecord.userId === userId) {
|
||||
hasAccess = true;
|
||||
}
|
||||
} catch (err) {}
|
||||
}
|
||||
|
||||
if (!hasAccess) {
|
||||
return reply.status(401).send({ error: "Unauthorized access to file." });
|
||||
}
|
||||
|
||||
const fileName = fileRecord.name;
|
||||
const expires = 3600;
|
||||
const expires = parseInt(env.PRESIGNED_URL_EXPIRATION);
|
||||
const url = await this.fileService.getPresignedGetUrl(objectName, expires, fileName);
|
||||
return reply.send({ url, expiresIn: expires });
|
||||
} catch (error) {
|
||||
@@ -201,6 +272,118 @@ export class FileController {
|
||||
}
|
||||
}
|
||||
|
||||
async downloadFile(request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
const { objectName, password } = request.query as {
|
||||
objectName: string;
|
||||
password?: string;
|
||||
};
|
||||
|
||||
if (!objectName) {
|
||||
return reply.status(400).send({ error: "The 'objectName' parameter is required." });
|
||||
}
|
||||
|
||||
const fileRecord = await prisma.file.findFirst({ where: { objectName } });
|
||||
|
||||
if (!fileRecord) {
|
||||
if (objectName.startsWith("reverse-shares/")) {
|
||||
const reverseShareFile = await prisma.reverseShareFile.findFirst({
|
||||
where: { objectName },
|
||||
include: {
|
||||
reverseShare: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!reverseShareFile) {
|
||||
return reply.status(404).send({ error: "File not found." });
|
||||
}
|
||||
|
||||
try {
|
||||
await request.jwtVerify();
|
||||
const userId = (request as any).user?.userId;
|
||||
|
||||
if (!userId || reverseShareFile.reverseShare.creatorId !== userId) {
|
||||
return reply.status(401).send({ error: "Unauthorized access to file." });
|
||||
}
|
||||
} catch (err) {
|
||||
return reply.status(401).send({ error: "Unauthorized access to file." });
|
||||
}
|
||||
|
||||
const storageProvider = (this.fileService as any).storageProvider;
|
||||
const filePath = storageProvider.getFilePath(objectName);
|
||||
|
||||
const contentType = getContentType(reverseShareFile.name);
|
||||
const fileName = reverseShareFile.name;
|
||||
|
||||
reply.header("Content-Type", contentType);
|
||||
reply.header("Content-Disposition", `inline; filename="${encodeURIComponent(fileName)}"`);
|
||||
|
||||
const stream = fs.createReadStream(filePath);
|
||||
return reply.send(stream);
|
||||
}
|
||||
|
||||
return reply.status(404).send({ error: "File not found." });
|
||||
}
|
||||
|
||||
let hasAccess = false;
|
||||
|
||||
const shares = await prisma.share.findMany({
|
||||
where: {
|
||||
files: {
|
||||
some: {
|
||||
id: fileRecord.id,
|
||||
},
|
||||
},
|
||||
},
|
||||
include: {
|
||||
security: true,
|
||||
},
|
||||
});
|
||||
|
||||
for (const share of shares) {
|
||||
if (!share.security.password) {
|
||||
hasAccess = true;
|
||||
break;
|
||||
} else if (password) {
|
||||
const isPasswordValid = await bcrypt.compare(password, share.security.password);
|
||||
if (isPasswordValid) {
|
||||
hasAccess = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasAccess) {
|
||||
try {
|
||||
await request.jwtVerify();
|
||||
const userId = (request as any).user?.userId;
|
||||
if (userId && fileRecord.userId === userId) {
|
||||
hasAccess = true;
|
||||
}
|
||||
} catch (err) {}
|
||||
}
|
||||
|
||||
if (!hasAccess) {
|
||||
return reply.status(401).send({ error: "Unauthorized access to file." });
|
||||
}
|
||||
|
||||
const storageProvider = (this.fileService as any).storageProvider;
|
||||
const filePath = storageProvider.getFilePath(objectName);
|
||||
|
||||
const contentType = getContentType(fileRecord.name);
|
||||
const fileName = fileRecord.name;
|
||||
|
||||
reply.header("Content-Type", contentType);
|
||||
reply.header("Content-Disposition", `inline; filename="${encodeURIComponent(fileName)}"`);
|
||||
|
||||
const stream = fs.createReadStream(filePath);
|
||||
return reply.send(stream);
|
||||
} catch (error) {
|
||||
console.error("Error in downloadFile:", error);
|
||||
return reply.status(500).send({ error: "Internal server error." });
|
||||
}
|
||||
}
|
||||
|
||||
async listFiles(request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
await request.jwtVerify();
|
||||
@@ -209,18 +392,43 @@ export class FileController {
|
||||
return reply.status(401).send({ error: "Unauthorized: a valid token is required to access this resource." });
|
||||
}
|
||||
|
||||
const files = await prisma.file.findMany({
|
||||
where: { userId },
|
||||
});
|
||||
const input: ListFilesInput = ListFilesSchema.parse(request.query);
|
||||
const { folderId, recursive: recursiveStr } = input;
|
||||
const recursive = recursiveStr === "false" ? false : true;
|
||||
|
||||
const filesResponse = files.map((file) => ({
|
||||
let files: any[];
|
||||
|
||||
let targetFolderId: string | null;
|
||||
if (folderId === "null" || folderId === "" || !folderId) {
|
||||
targetFolderId = null; // Root folder
|
||||
} else {
|
||||
targetFolderId = folderId;
|
||||
}
|
||||
|
||||
if (recursive) {
|
||||
if (targetFolderId === null) {
|
||||
files = await this.getAllUserFilesRecursively(userId);
|
||||
} else {
|
||||
const { FolderService } = await import("../folder/service.js");
|
||||
const folderService = new FolderService();
|
||||
files = await folderService.getAllFilesInFolder(targetFolderId, userId);
|
||||
}
|
||||
} else {
|
||||
files = await prisma.file.findMany({
|
||||
where: { userId, folderId: targetFolderId },
|
||||
});
|
||||
}
|
||||
|
||||
const filesResponse = files.map((file: any) => ({
|
||||
id: file.id,
|
||||
name: file.name,
|
||||
description: file.description,
|
||||
extension: file.extension,
|
||||
size: file.size.toString(),
|
||||
size: typeof file.size === "bigint" ? file.size.toString() : file.size,
|
||||
objectName: file.objectName,
|
||||
userId: file.userId,
|
||||
folderId: file.folderId,
|
||||
relativePath: file.relativePath || null,
|
||||
createdAt: file.createdAt,
|
||||
updatedAt: file.updatedAt,
|
||||
}));
|
||||
@@ -285,6 +493,13 @@ export class FileController {
|
||||
return reply.status(403).send({ error: "Access denied." });
|
||||
}
|
||||
|
||||
// If renaming the file, check for duplicates and auto-rename if necessary
|
||||
if (updateData.name && updateData.name !== fileRecord.name) {
|
||||
const { baseName, extension } = parseFileName(updateData.name);
|
||||
const uniqueName = await generateUniqueFileNameForRename(baseName, extension, userId, fileRecord.folderId, id);
|
||||
updateData.name = uniqueName;
|
||||
}
|
||||
|
||||
const updatedFile = await prisma.file.update({
|
||||
where: { id },
|
||||
data: updateData,
|
||||
@@ -298,6 +513,7 @@ export class FileController {
|
||||
size: updatedFile.size.toString(),
|
||||
objectName: updatedFile.objectName,
|
||||
userId: updatedFile.userId,
|
||||
folderId: updatedFile.folderId,
|
||||
createdAt: updatedFile.createdAt,
|
||||
updatedAt: updatedFile.updatedAt,
|
||||
};
|
||||
@@ -311,4 +527,131 @@ export class FileController {
|
||||
return reply.status(400).send({ error: error.message });
|
||||
}
|
||||
}
|
||||
|
||||
async moveFile(request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
await request.jwtVerify();
|
||||
const userId = (request as any).user?.userId;
|
||||
|
||||
if (!userId) {
|
||||
return reply.status(401).send({ error: "Unauthorized: a valid token is required to access this resource." });
|
||||
}
|
||||
|
||||
const { id } = request.params as { id: string };
|
||||
const input: MoveFileInput = MoveFileSchema.parse(request.body);
|
||||
|
||||
const existingFile = await prisma.file.findFirst({
|
||||
where: { id, userId },
|
||||
});
|
||||
|
||||
if (!existingFile) {
|
||||
return reply.status(404).send({ error: "File not found." });
|
||||
}
|
||||
|
||||
if (input.folderId) {
|
||||
const targetFolder = await prisma.folder.findFirst({
|
||||
where: { id: input.folderId, userId },
|
||||
});
|
||||
if (!targetFolder) {
|
||||
return reply.status(400).send({ error: "Target folder not found." });
|
||||
}
|
||||
}
|
||||
|
||||
const updatedFile = await prisma.file.update({
|
||||
where: { id },
|
||||
data: { folderId: input.folderId },
|
||||
});
|
||||
|
||||
const fileResponse = {
|
||||
id: updatedFile.id,
|
||||
name: updatedFile.name,
|
||||
description: updatedFile.description,
|
||||
extension: updatedFile.extension,
|
||||
size: updatedFile.size.toString(),
|
||||
objectName: updatedFile.objectName,
|
||||
userId: updatedFile.userId,
|
||||
folderId: updatedFile.folderId,
|
||||
createdAt: updatedFile.createdAt,
|
||||
updatedAt: updatedFile.updatedAt,
|
||||
};
|
||||
|
||||
return reply.send({
|
||||
file: fileResponse,
|
||||
message: "File moved successfully.",
|
||||
});
|
||||
} catch (error: any) {
|
||||
console.error("Error moving file:", error);
|
||||
return reply.status(400).send({ error: error.message });
|
||||
}
|
||||
}
|
||||
|
||||
async embedFile(request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
const { id } = request.params as { id: string };
|
||||
|
||||
if (!id) {
|
||||
return reply.status(400).send({ error: "File ID is required." });
|
||||
}
|
||||
|
||||
const fileRecord = await prisma.file.findUnique({ where: { id } });
|
||||
|
||||
if (!fileRecord) {
|
||||
return reply.status(404).send({ error: "File not found." });
|
||||
}
|
||||
|
||||
const extension = fileRecord.extension.toLowerCase();
|
||||
const imageExts = ["jpg", "jpeg", "png", "gif", "webp", "svg", "bmp", "ico", "avif"];
|
||||
const videoExts = ["mp4", "webm", "ogg", "mov", "avi", "mkv", "flv", "wmv"];
|
||||
const audioExts = ["mp3", "wav", "ogg", "m4a", "flac", "aac", "wma"];
|
||||
|
||||
const isMedia = imageExts.includes(extension) || videoExts.includes(extension) || audioExts.includes(extension);
|
||||
|
||||
if (!isMedia) {
|
||||
return reply.status(403).send({
|
||||
error: "Embed is only allowed for images, videos, and audio files.",
|
||||
});
|
||||
}
|
||||
|
||||
const storageProvider = (this.fileService as any).storageProvider;
|
||||
const filePath = storageProvider.getFilePath(fileRecord.objectName);
|
||||
|
||||
const contentType = getContentType(fileRecord.name);
|
||||
const fileName = fileRecord.name;
|
||||
|
||||
reply.header("Content-Type", contentType);
|
||||
reply.header("Content-Disposition", `inline; filename="${encodeURIComponent(fileName)}"`);
|
||||
reply.header("Cache-Control", "public, max-age=31536000"); // Cache por 1 ano
|
||||
|
||||
const stream = fs.createReadStream(filePath);
|
||||
return reply.send(stream);
|
||||
} catch (error) {
|
||||
console.error("Error in embedFile:", error);
|
||||
return reply.status(500).send({ error: "Internal server error." });
|
||||
}
|
||||
}
|
||||
|
||||
private async getAllUserFilesRecursively(userId: string): Promise<any[]> {
|
||||
const rootFiles = await prisma.file.findMany({
|
||||
where: { userId, folderId: null },
|
||||
});
|
||||
|
||||
const rootFolders = await prisma.folder.findMany({
|
||||
where: { userId, parentId: null },
|
||||
select: { id: true },
|
||||
});
|
||||
|
||||
let allFiles = [...rootFiles];
|
||||
|
||||
if (rootFolders.length > 0) {
|
||||
const { FolderService } = await import("../folder/service.js");
|
||||
const folderService = new FolderService();
|
||||
|
||||
for (const folder of rootFolders) {
|
||||
const folderFiles = await folderService.getAllFilesInFolder(folder.id, userId);
|
||||
allFiles = [...allFiles, ...folderFiles];
|
||||
}
|
||||
}
|
||||
|
||||
return allFiles;
|
||||
}
|
||||
}
|
||||
|
@@ -9,6 +9,7 @@ export const RegisterFileSchema = z.object({
|
||||
invalid_type_error: "O tamanho deve ser um número",
|
||||
}),
|
||||
objectName: z.string().min(1, "O objectName é obrigatório"),
|
||||
folderId: z.string().optional(),
|
||||
});
|
||||
|
||||
export const CheckFileSchema = z.object({
|
||||
@@ -20,6 +21,7 @@ export const CheckFileSchema = z.object({
|
||||
invalid_type_error: "O tamanho deve ser um número",
|
||||
}),
|
||||
objectName: z.string().min(1, "O objectName é obrigatório"),
|
||||
folderId: z.string().optional(),
|
||||
});
|
||||
|
||||
export type RegisterFileInput = z.infer<typeof RegisterFileSchema>;
|
||||
@@ -30,4 +32,15 @@ export const UpdateFileSchema = z.object({
|
||||
description: z.string().optional().nullable().describe("The file description"),
|
||||
});
|
||||
|
||||
export const MoveFileSchema = z.object({
|
||||
folderId: z.string().nullable(),
|
||||
});
|
||||
|
||||
export const ListFilesSchema = z.object({
|
||||
folderId: z.string().optional().describe("The folder ID"),
|
||||
recursive: z.string().optional().default("true").describe("Include files from subfolders"),
|
||||
});
|
||||
|
||||
export type UpdateFileInput = z.infer<typeof UpdateFileSchema>;
|
||||
export type MoveFileInput = z.infer<typeof MoveFileSchema>;
|
||||
export type ListFilesInput = z.infer<typeof ListFilesSchema>;
|
||||
|
@@ -2,7 +2,7 @@ import { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";
|
||||
import { z } from "zod";
|
||||
|
||||
import { FileController } from "./controller";
|
||||
import { CheckFileSchema, RegisterFileSchema, UpdateFileSchema } from "./dto";
|
||||
import { CheckFileSchema, ListFilesSchema, MoveFileSchema, RegisterFileSchema, UpdateFileSchema } from "./dto";
|
||||
|
||||
export async function fileRoutes(app: FastifyInstance) {
|
||||
const fileController = new FileController();
|
||||
@@ -62,6 +62,7 @@ export async function fileRoutes(app: FastifyInstance) {
|
||||
size: z.string().describe("The file size"),
|
||||
objectName: z.string().describe("The object name of the file"),
|
||||
userId: z.string().describe("The user ID"),
|
||||
folderId: z.string().nullable().describe("The folder ID"),
|
||||
createdAt: z.date().describe("The file creation date"),
|
||||
updatedAt: z.date().describe("The file last update date"),
|
||||
}),
|
||||
@@ -78,6 +79,7 @@ export async function fileRoutes(app: FastifyInstance) {
|
||||
app.post(
|
||||
"/files/check",
|
||||
{
|
||||
preValidation,
|
||||
schema: {
|
||||
tags: ["File"],
|
||||
operationId: "checkFile",
|
||||
@@ -104,15 +106,16 @@ export async function fileRoutes(app: FastifyInstance) {
|
||||
);
|
||||
|
||||
app.get(
|
||||
"/files/:objectName/download",
|
||||
"/files/download-url",
|
||||
{
|
||||
schema: {
|
||||
tags: ["File"],
|
||||
operationId: "getDownloadUrl",
|
||||
summary: "Get Download URL",
|
||||
description: "Generates a pre-signed URL for downloading a private file",
|
||||
params: z.object({
|
||||
description: "Generates a pre-signed URL for downloading a file",
|
||||
querystring: z.object({
|
||||
objectName: z.string().min(1, "The objectName is required"),
|
||||
password: z.string().optional().describe("Share password if required"),
|
||||
}),
|
||||
response: {
|
||||
200: z.object({
|
||||
@@ -128,6 +131,46 @@ export async function fileRoutes(app: FastifyInstance) {
|
||||
fileController.getDownloadUrl.bind(fileController)
|
||||
);
|
||||
|
||||
app.get(
|
||||
"/embed/:id",
|
||||
{
|
||||
schema: {
|
||||
tags: ["File"],
|
||||
operationId: "embedFile",
|
||||
summary: "Embed File (Public Access)",
|
||||
description:
|
||||
"Returns a media file (image/video/audio) for public embedding without authentication. Only works for media files.",
|
||||
params: z.object({
|
||||
id: z.string().min(1, "File ID is required").describe("The file ID"),
|
||||
}),
|
||||
response: {
|
||||
400: z.object({ error: z.string().describe("Error message") }),
|
||||
403: z.object({ error: z.string().describe("Error message - not a media file") }),
|
||||
404: z.object({ error: z.string().describe("Error message") }),
|
||||
500: z.object({ error: z.string().describe("Error message") }),
|
||||
},
|
||||
},
|
||||
},
|
||||
fileController.embedFile.bind(fileController)
|
||||
);
|
||||
|
||||
app.get(
|
||||
"/files/download",
|
||||
{
|
||||
schema: {
|
||||
tags: ["File"],
|
||||
operationId: "downloadFile",
|
||||
summary: "Download File",
|
||||
description: "Downloads a file directly (returns file content)",
|
||||
querystring: z.object({
|
||||
objectName: z.string().min(1, "The objectName is required"),
|
||||
password: z.string().optional().describe("Share password if required"),
|
||||
}),
|
||||
},
|
||||
},
|
||||
fileController.downloadFile.bind(fileController)
|
||||
);
|
||||
|
||||
app.get(
|
||||
"/files",
|
||||
{
|
||||
@@ -136,7 +179,8 @@ export async function fileRoutes(app: FastifyInstance) {
|
||||
tags: ["File"],
|
||||
operationId: "listFiles",
|
||||
summary: "List Files",
|
||||
description: "Lists user files",
|
||||
description: "Lists user files recursively by default, optionally filtered by folder",
|
||||
querystring: ListFilesSchema,
|
||||
response: {
|
||||
200: z.object({
|
||||
files: z.array(
|
||||
@@ -148,6 +192,8 @@ export async function fileRoutes(app: FastifyInstance) {
|
||||
size: z.string().describe("The file size"),
|
||||
objectName: z.string().describe("The object name of the file"),
|
||||
userId: z.string().describe("The user ID"),
|
||||
folderId: z.string().nullable().describe("The folder ID"),
|
||||
relativePath: z.string().nullable().describe("The relative path (only for recursive listing)"),
|
||||
createdAt: z.date().describe("The file creation date"),
|
||||
updatedAt: z.date().describe("The file last update date"),
|
||||
})
|
||||
@@ -160,6 +206,84 @@ export async function fileRoutes(app: FastifyInstance) {
|
||||
fileController.listFiles.bind(fileController)
|
||||
);
|
||||
|
||||
app.patch(
|
||||
"/files/:id",
|
||||
{
|
||||
preValidation,
|
||||
schema: {
|
||||
tags: ["File"],
|
||||
operationId: "updateFile",
|
||||
summary: "Update File Metadata",
|
||||
description: "Updates file metadata in the database",
|
||||
params: z.object({
|
||||
id: z.string().min(1, "The file id is required").describe("The file ID"),
|
||||
}),
|
||||
body: UpdateFileSchema,
|
||||
response: {
|
||||
200: z.object({
|
||||
file: z.object({
|
||||
id: z.string().describe("The file ID"),
|
||||
name: z.string().describe("The file name"),
|
||||
description: z.string().nullable().describe("The file description"),
|
||||
extension: z.string().describe("The file extension"),
|
||||
size: z.string().describe("The file size"),
|
||||
objectName: z.string().describe("The object name of the file"),
|
||||
userId: z.string().describe("The user ID"),
|
||||
folderId: z.string().nullable().describe("The folder ID"),
|
||||
createdAt: z.date().describe("The file creation date"),
|
||||
updatedAt: z.date().describe("The file last update date"),
|
||||
}),
|
||||
message: z.string().describe("Success message"),
|
||||
}),
|
||||
400: z.object({ error: z.string().describe("Error message") }),
|
||||
401: z.object({ error: z.string().describe("Error message") }),
|
||||
403: z.object({ error: z.string().describe("Error message") }),
|
||||
404: z.object({ error: z.string().describe("Error message") }),
|
||||
},
|
||||
},
|
||||
},
|
||||
fileController.updateFile.bind(fileController)
|
||||
);
|
||||
|
||||
app.put(
|
||||
"/files/:id/move",
|
||||
{
|
||||
preValidation,
|
||||
schema: {
|
||||
tags: ["File"],
|
||||
operationId: "moveFile",
|
||||
summary: "Move File",
|
||||
description: "Moves a file to a different folder",
|
||||
params: z.object({
|
||||
id: z.string().min(1, "The file id is required").describe("The file ID"),
|
||||
}),
|
||||
body: MoveFileSchema,
|
||||
response: {
|
||||
200: z.object({
|
||||
file: z.object({
|
||||
id: z.string().describe("The file ID"),
|
||||
name: z.string().describe("The file name"),
|
||||
description: z.string().nullable().describe("The file description"),
|
||||
extension: z.string().describe("The file extension"),
|
||||
size: z.string().describe("The file size"),
|
||||
objectName: z.string().describe("The object name of the file"),
|
||||
userId: z.string().describe("The user ID"),
|
||||
folderId: z.string().nullable().describe("The folder ID"),
|
||||
createdAt: z.date().describe("The file creation date"),
|
||||
updatedAt: z.date().describe("The file last update date"),
|
||||
}),
|
||||
message: z.string().describe("Success message"),
|
||||
}),
|
||||
400: z.object({ error: z.string().describe("Error message") }),
|
||||
401: z.object({ error: z.string().describe("Error message") }),
|
||||
403: z.object({ error: z.string().describe("Error message") }),
|
||||
404: z.object({ error: z.string().describe("Error message") }),
|
||||
},
|
||||
},
|
||||
},
|
||||
fileController.moveFile.bind(fileController)
|
||||
);
|
||||
|
||||
app.delete(
|
||||
"/files/:id",
|
||||
{
|
||||
@@ -185,42 +309,4 @@ export async function fileRoutes(app: FastifyInstance) {
|
||||
},
|
||||
fileController.deleteFile.bind(fileController)
|
||||
);
|
||||
|
||||
app.patch(
|
||||
"/files/:id",
|
||||
{
|
||||
preValidation,
|
||||
schema: {
|
||||
tags: ["File"],
|
||||
operationId: "updateFile",
|
||||
summary: "Update File Metadata",
|
||||
description: "Updates file metadata in the database",
|
||||
params: z.object({
|
||||
id: z.string().min(1, "The file id is required").describe("The file ID"),
|
||||
}),
|
||||
body: UpdateFileSchema,
|
||||
response: {
|
||||
200: z.object({
|
||||
file: z.object({
|
||||
id: z.string().describe("The file ID"),
|
||||
name: z.string().describe("The file name"),
|
||||
description: z.string().nullable().describe("The file description"),
|
||||
extension: z.string().describe("The file extension"),
|
||||
size: z.string().describe("The file size"),
|
||||
objectName: z.string().describe("The object name of the file"),
|
||||
userId: z.string().describe("The user ID"),
|
||||
createdAt: z.date().describe("The file creation date"),
|
||||
updatedAt: z.date().describe("The file last update date"),
|
||||
}),
|
||||
message: z.string().describe("Success message"),
|
||||
}),
|
||||
400: z.object({ error: z.string().describe("Error message") }),
|
||||
401: z.object({ error: z.string().describe("Error message") }),
|
||||
403: z.object({ error: z.string().describe("Error message") }),
|
||||
404: z.object({ error: z.string().describe("Error message") }),
|
||||
},
|
||||
},
|
||||
},
|
||||
fileController.updateFile.bind(fileController)
|
||||
);
|
||||
}
|
||||
|
@@ -3,10 +3,28 @@ import { pipeline } from "stream/promises";
|
||||
import { FastifyReply, FastifyRequest } from "fastify";
|
||||
|
||||
import { FilesystemStorageProvider } from "../../providers/filesystem-storage.provider";
|
||||
import { DownloadCancelResponse, QueueClearResponse, QueueStatusResponse } from "../../types/download-queue";
|
||||
import { DownloadMemoryManager } from "../../utils/download-memory-manager";
|
||||
import { getContentType } from "../../utils/mime-types";
|
||||
import { ChunkManager, ChunkMetadata } from "./chunk-manager";
|
||||
|
||||
export class FilesystemController {
|
||||
private chunkManager = ChunkManager.getInstance();
|
||||
private memoryManager = DownloadMemoryManager.getInstance();
|
||||
|
||||
/**
|
||||
* Check if a character is valid in an HTTP token (RFC 2616)
|
||||
* Tokens can contain: alphanumeric and !#$%&'*+-.^_`|~
|
||||
* Must exclude separators: ()<>@,;:\"/[]?={} and space/tab
|
||||
*/
|
||||
private isTokenChar(char: string): boolean {
|
||||
const code = char.charCodeAt(0);
|
||||
// Basic ASCII range check
|
||||
if (code < 33 || code > 126) return false;
|
||||
// Exclude separator characters per RFC 2616
|
||||
const separators = '()<>@,;:\\"/[]?={} \t';
|
||||
return !separators.includes(char);
|
||||
}
|
||||
|
||||
private encodeFilenameForHeader(filename: string): string {
|
||||
if (!filename || filename.trim() === "") {
|
||||
@@ -32,12 +50,10 @@ export class FilesystemController {
|
||||
return 'attachment; filename="download"';
|
||||
}
|
||||
|
||||
// Create ASCII-safe version with only valid token characters
|
||||
const asciiSafe = sanitized
|
||||
.split("")
|
||||
.filter((char) => {
|
||||
const code = char.charCodeAt(0);
|
||||
return code >= 32 && code <= 126;
|
||||
})
|
||||
.filter((char) => this.isTokenChar(char))
|
||||
.join("");
|
||||
|
||||
if (asciiSafe && asciiSafe.trim()) {
|
||||
@@ -68,7 +84,6 @@ export class FilesystemController {
|
||||
const result = await this.handleChunkedUpload(request, chunkMetadata, tokenData.objectName);
|
||||
|
||||
if (result.isComplete) {
|
||||
provider.consumeUploadToken(token);
|
||||
reply.status(200).send({
|
||||
message: "File uploaded successfully",
|
||||
objectName: result.finalPath,
|
||||
@@ -88,7 +103,6 @@ export class FilesystemController {
|
||||
}
|
||||
} else {
|
||||
await this.uploadFileStream(request, provider, tokenData.objectName);
|
||||
provider.consumeUploadToken(token);
|
||||
reply.status(200).send({ message: "File uploaded successfully" });
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -106,13 +120,22 @@ export class FilesystemController {
|
||||
const totalChunks = request.headers["x-total-chunks"] as string;
|
||||
const chunkSize = request.headers["x-chunk-size"] as string;
|
||||
const totalSize = request.headers["x-total-size"] as string;
|
||||
const fileName = request.headers["x-file-name"] as string;
|
||||
const encodedFileName = request.headers["x-file-name"] as string;
|
||||
const isLastChunk = request.headers["x-is-last-chunk"] as string;
|
||||
|
||||
if (!fileId || !chunkIndex || !totalChunks || !chunkSize || !totalSize || !fileName) {
|
||||
if (!fileId || !chunkIndex || !totalChunks || !chunkSize || !totalSize || !encodedFileName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Decode the base64-encoded filename to handle UTF-8 characters
|
||||
let fileName: string;
|
||||
try {
|
||||
fileName = decodeURIComponent(escape(Buffer.from(encodedFileName, "base64").toString("binary")));
|
||||
} catch (error) {
|
||||
// Fallback to the encoded value if decoding fails (for backward compatibility)
|
||||
fileName = encodedFileName;
|
||||
}
|
||||
|
||||
const metadata = {
|
||||
fileId,
|
||||
chunkIndex: parseInt(chunkIndex, 10),
|
||||
@@ -165,9 +188,10 @@ export class FilesystemController {
|
||||
}
|
||||
|
||||
async download(request: FastifyRequest, reply: FastifyReply) {
|
||||
const downloadId = `${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;
|
||||
|
||||
try {
|
||||
const { token } = request.params as { token: string };
|
||||
|
||||
const provider = FilesystemStorageProvider.getInstance();
|
||||
|
||||
const tokenData = provider.validateDownloadToken(token);
|
||||
@@ -177,46 +201,98 @@ export class FilesystemController {
|
||||
}
|
||||
|
||||
const filePath = provider.getFilePath(tokenData.objectName);
|
||||
|
||||
const fileExists = await provider.fileExists(tokenData.objectName);
|
||||
if (!fileExists) {
|
||||
console.error(`[DOWNLOAD] File not found: ${tokenData.objectName}`);
|
||||
return reply.status(404).send({
|
||||
error: "File not found",
|
||||
message:
|
||||
"The requested file does not exist on the server. It may have been deleted or the upload was incomplete.",
|
||||
});
|
||||
}
|
||||
|
||||
const stats = await fs.promises.stat(filePath);
|
||||
const fileSize = stats.size;
|
||||
|
||||
const fileName = tokenData.fileName || "download";
|
||||
|
||||
const fileSizeMB = fileSize / (1024 * 1024);
|
||||
console.log(`[DOWNLOAD] Requesting slot for ${downloadId}: ${tokenData.objectName} (${fileSizeMB.toFixed(1)}MB)`);
|
||||
|
||||
try {
|
||||
await this.memoryManager.requestDownloadSlot(downloadId, {
|
||||
fileName,
|
||||
fileSize,
|
||||
objectName: tokenData.objectName,
|
||||
});
|
||||
} catch (error: any) {
|
||||
console.warn(`[DOWNLOAD] Queue full for ${downloadId}: ${error.message}`);
|
||||
return reply.status(503).send({
|
||||
error: "Download queue is full",
|
||||
message: error.message,
|
||||
retryAfter: 60,
|
||||
});
|
||||
}
|
||||
|
||||
console.log(`[DOWNLOAD] Starting ${downloadId}: ${tokenData.objectName} (${fileSizeMB.toFixed(1)}MB)`);
|
||||
this.memoryManager.startDownload(downloadId);
|
||||
|
||||
const range = request.headers.range;
|
||||
|
||||
reply.header("Content-Disposition", this.encodeFilenameForHeader(fileName));
|
||||
reply.header("Content-Type", "application/octet-stream");
|
||||
reply.header("Content-Type", getContentType(fileName));
|
||||
reply.header("Accept-Ranges", "bytes");
|
||||
reply.header("X-Download-ID", downloadId);
|
||||
|
||||
if (range) {
|
||||
const parts = range.replace(/bytes=/, "").split("-");
|
||||
const start = parseInt(parts[0], 10);
|
||||
const end = parts[1] ? parseInt(parts[1], 10) : fileSize - 1;
|
||||
reply.raw.on("close", () => {
|
||||
this.memoryManager.endDownload(downloadId);
|
||||
console.log(`[DOWNLOAD] Client disconnected: ${downloadId}`);
|
||||
});
|
||||
|
||||
reply.status(206);
|
||||
reply.header("Content-Range", `bytes ${start}-${end}/${fileSize}`);
|
||||
reply.header("Content-Length", end - start + 1);
|
||||
reply.raw.on("error", () => {
|
||||
this.memoryManager.endDownload(downloadId);
|
||||
console.log(`[DOWNLOAD] Client error: ${downloadId}`);
|
||||
});
|
||||
|
||||
await this.downloadFileRange(reply, provider, tokenData.objectName, start, end);
|
||||
} else {
|
||||
reply.header("Content-Length", fileSize);
|
||||
await this.downloadFileStream(reply, provider, tokenData.objectName);
|
||||
try {
|
||||
if (range) {
|
||||
const parts = range.replace(/bytes=/, "").split("-");
|
||||
const start = parseInt(parts[0], 10);
|
||||
const end = parts[1] ? parseInt(parts[1], 10) : fileSize - 1;
|
||||
|
||||
reply.status(206);
|
||||
reply.header("Content-Range", `bytes ${start}-${end}/${fileSize}`);
|
||||
reply.header("Content-Length", end - start + 1);
|
||||
|
||||
await this.downloadFileRange(reply, provider, tokenData.objectName, start, end, downloadId);
|
||||
} else {
|
||||
reply.header("Content-Length", fileSize);
|
||||
await this.downloadFileStream(reply, provider, tokenData.objectName, downloadId);
|
||||
}
|
||||
} finally {
|
||||
this.memoryManager.endDownload(downloadId);
|
||||
}
|
||||
|
||||
provider.consumeDownloadToken(token);
|
||||
} catch (error) {
|
||||
this.memoryManager.endDownload(downloadId);
|
||||
console.error(`[DOWNLOAD] Error in ${downloadId}:`, error);
|
||||
return reply.status(500).send({ error: "Internal server error" });
|
||||
}
|
||||
}
|
||||
|
||||
private async downloadFileStream(reply: FastifyReply, provider: FilesystemStorageProvider, objectName: string) {
|
||||
private async downloadFileStream(
|
||||
reply: FastifyReply,
|
||||
provider: FilesystemStorageProvider,
|
||||
objectName: string,
|
||||
downloadId?: string
|
||||
) {
|
||||
try {
|
||||
FilesystemStorageProvider.logMemoryUsage(`Download start: ${objectName}`);
|
||||
FilesystemStorageProvider.logMemoryUsage(`Download start: ${objectName} (${downloadId})`);
|
||||
|
||||
const downloadStream = provider.createDownloadStream(objectName);
|
||||
|
||||
downloadStream.on("error", (error) => {
|
||||
console.error("Download stream error:", error);
|
||||
FilesystemStorageProvider.logMemoryUsage(`Download error: ${objectName}`);
|
||||
FilesystemStorageProvider.logMemoryUsage(`Download error: ${objectName} (${downloadId})`);
|
||||
if (!reply.sent) {
|
||||
reply.status(500).send({ error: "Download failed" });
|
||||
}
|
||||
@@ -226,15 +302,40 @@ export class FilesystemController {
|
||||
if (downloadStream.readable && typeof (downloadStream as any).destroy === "function") {
|
||||
(downloadStream as any).destroy();
|
||||
}
|
||||
FilesystemStorageProvider.logMemoryUsage(`Download client disconnect: ${objectName}`);
|
||||
FilesystemStorageProvider.logMemoryUsage(`Download client disconnect: ${objectName} (${downloadId})`);
|
||||
});
|
||||
|
||||
await pipeline(downloadStream, reply.raw);
|
||||
if (this.memoryManager.shouldThrottleStream()) {
|
||||
console.log(
|
||||
`[MEMORY THROTTLE] ${objectName} - Pausing stream due to high memory usage: ${this.memoryManager.getCurrentMemoryUsageMB().toFixed(0)}MB`
|
||||
);
|
||||
|
||||
FilesystemStorageProvider.logMemoryUsage(`Download complete: ${objectName}`);
|
||||
const { Transform } = require("stream");
|
||||
const memoryManager = this.memoryManager;
|
||||
const throttleStream = new Transform({
|
||||
highWaterMark: 256 * 1024,
|
||||
transform(chunk: Buffer, _encoding: BufferEncoding, callback: (error?: Error | null, data?: any) => void) {
|
||||
if (memoryManager.shouldThrottleStream()) {
|
||||
setImmediate(() => {
|
||||
this.push(chunk);
|
||||
callback();
|
||||
});
|
||||
} else {
|
||||
this.push(chunk);
|
||||
callback();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
await pipeline(downloadStream, throttleStream, reply.raw);
|
||||
} else {
|
||||
await pipeline(downloadStream, reply.raw);
|
||||
}
|
||||
|
||||
FilesystemStorageProvider.logMemoryUsage(`Download complete: ${objectName} (${downloadId})`);
|
||||
} catch (error) {
|
||||
console.error("Download error:", error);
|
||||
FilesystemStorageProvider.logMemoryUsage(`Download failed: ${objectName}`);
|
||||
FilesystemStorageProvider.logMemoryUsage(`Download failed: ${objectName} (${downloadId})`);
|
||||
if (!reply.sent) {
|
||||
reply.status(500).send({ error: "Download failed" });
|
||||
}
|
||||
@@ -246,16 +347,19 @@ export class FilesystemController {
|
||||
provider: FilesystemStorageProvider,
|
||||
objectName: string,
|
||||
start: number,
|
||||
end: number
|
||||
end: number,
|
||||
downloadId?: string
|
||||
) {
|
||||
try {
|
||||
FilesystemStorageProvider.logMemoryUsage(`Range download start: ${objectName} (${start}-${end})`);
|
||||
FilesystemStorageProvider.logMemoryUsage(`Range download start: ${objectName} (${start}-${end}) (${downloadId})`);
|
||||
|
||||
const rangeStream = await provider.createDownloadRangeStream(objectName, start, end);
|
||||
|
||||
rangeStream.on("error", (error) => {
|
||||
console.error("Range download stream error:", error);
|
||||
FilesystemStorageProvider.logMemoryUsage(`Range download error: ${objectName} (${start}-${end})`);
|
||||
FilesystemStorageProvider.logMemoryUsage(
|
||||
`Range download error: ${objectName} (${start}-${end}) (${downloadId})`
|
||||
);
|
||||
if (!reply.sent) {
|
||||
reply.status(500).send({ error: "Download failed" });
|
||||
}
|
||||
@@ -265,18 +369,76 @@ export class FilesystemController {
|
||||
if (rangeStream.readable && typeof (rangeStream as any).destroy === "function") {
|
||||
(rangeStream as any).destroy();
|
||||
}
|
||||
FilesystemStorageProvider.logMemoryUsage(`Range download client disconnect: ${objectName} (${start}-${end})`);
|
||||
FilesystemStorageProvider.logMemoryUsage(
|
||||
`Range download client disconnect: ${objectName} (${start}-${end}) (${downloadId})`
|
||||
);
|
||||
});
|
||||
|
||||
await pipeline(rangeStream, reply.raw);
|
||||
|
||||
FilesystemStorageProvider.logMemoryUsage(`Range download complete: ${objectName} (${start}-${end})`);
|
||||
FilesystemStorageProvider.logMemoryUsage(
|
||||
`Range download complete: ${objectName} (${start}-${end}) (${downloadId})`
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("Range download error:", error);
|
||||
FilesystemStorageProvider.logMemoryUsage(`Range download failed: ${objectName} (${start}-${end})`);
|
||||
FilesystemStorageProvider.logMemoryUsage(
|
||||
`Range download failed: ${objectName} (${start}-${end}) (${downloadId})`
|
||||
);
|
||||
if (!reply.sent) {
|
||||
reply.status(500).send({ error: "Download failed" });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async getQueueStatus(_request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
const queueStatus = this.memoryManager.getQueueStatus();
|
||||
const response: QueueStatusResponse = {
|
||||
status: "success",
|
||||
data: queueStatus,
|
||||
};
|
||||
reply.status(200).send(response);
|
||||
} catch (error) {
|
||||
console.error("Error getting queue status:", error);
|
||||
return reply.status(500).send({ error: "Internal server error" });
|
||||
}
|
||||
}
|
||||
|
||||
async cancelQueuedDownload(request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
const { downloadId } = request.params as { downloadId: string };
|
||||
|
||||
const cancelled = this.memoryManager.cancelQueuedDownload(downloadId);
|
||||
|
||||
if (cancelled) {
|
||||
const response: DownloadCancelResponse = {
|
||||
message: "Download cancelled successfully",
|
||||
downloadId,
|
||||
};
|
||||
reply.status(200).send(response);
|
||||
} else {
|
||||
reply.status(404).send({
|
||||
error: "Download not found in queue",
|
||||
downloadId,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error cancelling queued download:", error);
|
||||
return reply.status(500).send({ error: "Internal server error" });
|
||||
}
|
||||
}
|
||||
|
||||
async clearDownloadQueue(_request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
const clearedCount = this.memoryManager.clearQueue();
|
||||
const response: QueueClearResponse = {
|
||||
message: "Download queue cleared successfully",
|
||||
clearedCount,
|
||||
};
|
||||
reply.status(200).send(response);
|
||||
} catch (error) {
|
||||
console.error("Error clearing download queue:", error);
|
||||
return reply.status(500).send({ error: "Internal server error" });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
95
apps/server/src/modules/filesystem/download-queue-routes.ts
Normal file
95
apps/server/src/modules/filesystem/download-queue-routes.ts
Normal file
@@ -0,0 +1,95 @@
|
||||
import { FastifyInstance } from "fastify";
|
||||
import { z } from "zod";
|
||||
|
||||
import { FilesystemController } from "./controller";
|
||||
|
||||
export async function downloadQueueRoutes(app: FastifyInstance) {
|
||||
const filesystemController = new FilesystemController();
|
||||
|
||||
app.get(
|
||||
"/filesystem/download-queue/status",
|
||||
{
|
||||
schema: {
|
||||
tags: ["Download Queue"],
|
||||
operationId: "getDownloadQueueStatus",
|
||||
summary: "Get download queue status",
|
||||
description: "Get current status of the download queue including active downloads and queue length",
|
||||
response: {
|
||||
200: z.object({
|
||||
status: z.string(),
|
||||
data: z.object({
|
||||
queueLength: z.number(),
|
||||
maxQueueSize: z.number(),
|
||||
activeDownloads: z.number(),
|
||||
maxConcurrent: z.number(),
|
||||
queuedDownloads: z.array(
|
||||
z.object({
|
||||
downloadId: z.string(),
|
||||
position: z.number(),
|
||||
waitTime: z.number(),
|
||||
fileName: z.string().optional(),
|
||||
fileSize: z.number().optional(),
|
||||
})
|
||||
),
|
||||
}),
|
||||
}),
|
||||
500: z.object({
|
||||
error: z.string(),
|
||||
}),
|
||||
},
|
||||
},
|
||||
},
|
||||
filesystemController.getQueueStatus.bind(filesystemController)
|
||||
);
|
||||
|
||||
app.delete(
|
||||
"/filesystem/download-queue/:downloadId",
|
||||
{
|
||||
schema: {
|
||||
tags: ["Download Queue"],
|
||||
operationId: "cancelQueuedDownload",
|
||||
summary: "Cancel a queued download",
|
||||
description: "Cancel a specific download that is waiting in the queue",
|
||||
params: z.object({
|
||||
downloadId: z.string().describe("Download ID"),
|
||||
}),
|
||||
response: {
|
||||
200: z.object({
|
||||
message: z.string(),
|
||||
downloadId: z.string(),
|
||||
}),
|
||||
404: z.object({
|
||||
error: z.string(),
|
||||
downloadId: z.string(),
|
||||
}),
|
||||
500: z.object({
|
||||
error: z.string(),
|
||||
}),
|
||||
},
|
||||
},
|
||||
},
|
||||
filesystemController.cancelQueuedDownload.bind(filesystemController)
|
||||
);
|
||||
|
||||
app.delete(
|
||||
"/filesystem/download-queue",
|
||||
{
|
||||
schema: {
|
||||
tags: ["Download Queue"],
|
||||
operationId: "clearDownloadQueue",
|
||||
summary: "Clear entire download queue",
|
||||
description: "Cancel all downloads waiting in the queue (admin operation)",
|
||||
response: {
|
||||
200: z.object({
|
||||
message: z.string(),
|
||||
clearedCount: z.number(),
|
||||
}),
|
||||
500: z.object({
|
||||
error: z.string(),
|
||||
}),
|
||||
},
|
||||
},
|
||||
},
|
||||
filesystemController.clearDownloadQueue.bind(filesystemController)
|
||||
);
|
||||
}
|
396
apps/server/src/modules/folder/controller.ts
Normal file
396
apps/server/src/modules/folder/controller.ts
Normal file
@@ -0,0 +1,396 @@
|
||||
import { FastifyReply, FastifyRequest } from "fastify";
|
||||
|
||||
import { env } from "../../env";
|
||||
import { prisma } from "../../shared/prisma";
|
||||
import { ConfigService } from "../config/service";
|
||||
import {
|
||||
CheckFolderSchema,
|
||||
ListFoldersSchema,
|
||||
MoveFolderSchema,
|
||||
RegisterFolderSchema,
|
||||
UpdateFolderSchema,
|
||||
} from "./dto";
|
||||
import { FolderService } from "./service";
|
||||
|
||||
export class FolderController {
|
||||
private folderService = new FolderService();
|
||||
private configService = new ConfigService();
|
||||
|
||||
async registerFolder(request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
await request.jwtVerify();
|
||||
const userId = (request as any).user?.userId;
|
||||
if (!userId) {
|
||||
return reply.status(401).send({ error: "Unauthorized: a valid token is required to access this resource." });
|
||||
}
|
||||
|
||||
const input = RegisterFolderSchema.parse(request.body);
|
||||
|
||||
if (input.parentId) {
|
||||
const parentFolder = await prisma.folder.findFirst({
|
||||
where: { id: input.parentId, userId },
|
||||
});
|
||||
if (!parentFolder) {
|
||||
return reply.status(400).send({ error: "Parent folder not found or access denied" });
|
||||
}
|
||||
}
|
||||
|
||||
// Check for duplicates and auto-rename if necessary
|
||||
const { generateUniqueFolderName } = await import("../../utils/file-name-generator.js");
|
||||
const uniqueName = await generateUniqueFolderName(input.name, userId, input.parentId);
|
||||
|
||||
const folderRecord = await prisma.folder.create({
|
||||
data: {
|
||||
name: uniqueName,
|
||||
description: input.description,
|
||||
objectName: input.objectName,
|
||||
parentId: input.parentId,
|
||||
userId,
|
||||
},
|
||||
include: {
|
||||
_count: {
|
||||
select: {
|
||||
files: true,
|
||||
children: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const totalSize = await this.folderService.calculateFolderSize(folderRecord.id, userId);
|
||||
|
||||
const folderResponse = {
|
||||
id: folderRecord.id,
|
||||
name: folderRecord.name,
|
||||
description: folderRecord.description,
|
||||
objectName: folderRecord.objectName,
|
||||
parentId: folderRecord.parentId,
|
||||
userId: folderRecord.userId,
|
||||
createdAt: folderRecord.createdAt,
|
||||
updatedAt: folderRecord.updatedAt,
|
||||
totalSize: totalSize.toString(),
|
||||
_count: folderRecord._count,
|
||||
};
|
||||
|
||||
return reply.status(201).send({
|
||||
folder: folderResponse,
|
||||
message: "Folder registered successfully.",
|
||||
});
|
||||
} catch (error: any) {
|
||||
console.error("Error in registerFolder:", error);
|
||||
return reply.status(400).send({ error: error.message });
|
||||
}
|
||||
}
|
||||
|
||||
async checkFolder(request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
await request.jwtVerify();
|
||||
const userId = (request as any).user?.userId;
|
||||
if (!userId) {
|
||||
return reply.status(401).send({
|
||||
error: "Unauthorized: a valid token is required to access this resource.",
|
||||
code: "unauthorized",
|
||||
});
|
||||
}
|
||||
|
||||
const input = CheckFolderSchema.parse(request.body);
|
||||
|
||||
if (input.name.length > 100) {
|
||||
return reply.status(400).send({
|
||||
code: "folderNameTooLong",
|
||||
error: "Folder name exceeds maximum length of 100 characters",
|
||||
details: "100",
|
||||
});
|
||||
}
|
||||
|
||||
const existingFolder = await prisma.folder.findFirst({
|
||||
where: {
|
||||
name: input.name,
|
||||
parentId: input.parentId || null,
|
||||
userId,
|
||||
},
|
||||
});
|
||||
|
||||
if (existingFolder) {
|
||||
return reply.status(400).send({
|
||||
error: "A folder with this name already exists in this location",
|
||||
code: "duplicateFolderName",
|
||||
});
|
||||
}
|
||||
|
||||
return reply.status(201).send({
|
||||
message: "Folder checks succeeded.",
|
||||
});
|
||||
} catch (error: any) {
|
||||
console.error("Error in checkFolder:", error);
|
||||
return reply.status(400).send({ error: error.message });
|
||||
}
|
||||
}
|
||||
|
||||
async listFolders(request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
await request.jwtVerify();
|
||||
const userId = (request as any).user?.userId;
|
||||
if (!userId) {
|
||||
return reply.status(401).send({ error: "Unauthorized: a valid token is required to access this resource." });
|
||||
}
|
||||
|
||||
const input = ListFoldersSchema.parse(request.query);
|
||||
const { parentId, recursive: recursiveStr } = input;
|
||||
const recursive = recursiveStr === "false" ? false : true;
|
||||
|
||||
let folders: any[];
|
||||
|
||||
if (recursive) {
|
||||
folders = await prisma.folder.findMany({
|
||||
where: { userId },
|
||||
include: {
|
||||
_count: {
|
||||
select: {
|
||||
files: true,
|
||||
children: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
orderBy: [{ name: "asc" }],
|
||||
});
|
||||
} else {
|
||||
// Get only direct children of specified parent
|
||||
const targetParentId = parentId === "null" || parentId === "" || !parentId ? null : parentId;
|
||||
folders = await prisma.folder.findMany({
|
||||
where: {
|
||||
userId,
|
||||
parentId: targetParentId,
|
||||
},
|
||||
include: {
|
||||
_count: {
|
||||
select: {
|
||||
files: true,
|
||||
children: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
orderBy: [{ name: "asc" }],
|
||||
});
|
||||
}
|
||||
|
||||
const foldersResponse = await Promise.all(
|
||||
folders.map(async (folder) => {
|
||||
const totalSize = await this.folderService.calculateFolderSize(folder.id, userId);
|
||||
return {
|
||||
id: folder.id,
|
||||
name: folder.name,
|
||||
description: folder.description,
|
||||
objectName: folder.objectName,
|
||||
parentId: folder.parentId,
|
||||
userId: folder.userId,
|
||||
createdAt: folder.createdAt,
|
||||
updatedAt: folder.updatedAt,
|
||||
totalSize: totalSize.toString(),
|
||||
_count: folder._count,
|
||||
};
|
||||
})
|
||||
);
|
||||
|
||||
return reply.send({ folders: foldersResponse });
|
||||
} catch (error: any) {
|
||||
console.error("Error in listFolders:", error);
|
||||
return reply.status(500).send({ error: error.message });
|
||||
}
|
||||
}
|
||||
|
||||
async updateFolder(request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
await request.jwtVerify();
|
||||
const { id } = request.params as { id: string };
|
||||
const userId = (request as any).user?.userId;
|
||||
|
||||
if (!userId) {
|
||||
return reply.status(401).send({
|
||||
error: "Unauthorized: a valid token is required to access this resource.",
|
||||
});
|
||||
}
|
||||
|
||||
const updateData = UpdateFolderSchema.parse(request.body);
|
||||
|
||||
const folderRecord = await prisma.folder.findUnique({ where: { id } });
|
||||
|
||||
if (!folderRecord) {
|
||||
return reply.status(404).send({ error: "Folder not found." });
|
||||
}
|
||||
|
||||
if (folderRecord.userId !== userId) {
|
||||
return reply.status(403).send({ error: "Access denied." });
|
||||
}
|
||||
|
||||
// If renaming the folder, check for duplicates and auto-rename if necessary
|
||||
if (updateData.name && updateData.name !== folderRecord.name) {
|
||||
const { generateUniqueFolderName } = await import("../../utils/file-name-generator.js");
|
||||
const uniqueName = await generateUniqueFolderName(updateData.name, userId, folderRecord.parentId, id);
|
||||
updateData.name = uniqueName;
|
||||
}
|
||||
|
||||
const updatedFolder = await prisma.folder.update({
|
||||
where: { id },
|
||||
data: updateData,
|
||||
include: {
|
||||
_count: {
|
||||
select: {
|
||||
files: true,
|
||||
children: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const totalSize = await this.folderService.calculateFolderSize(updatedFolder.id, userId);
|
||||
|
||||
const folderResponse = {
|
||||
id: updatedFolder.id,
|
||||
name: updatedFolder.name,
|
||||
description: updatedFolder.description,
|
||||
objectName: updatedFolder.objectName,
|
||||
parentId: updatedFolder.parentId,
|
||||
userId: updatedFolder.userId,
|
||||
createdAt: updatedFolder.createdAt,
|
||||
updatedAt: updatedFolder.updatedAt,
|
||||
totalSize: totalSize.toString(),
|
||||
_count: updatedFolder._count,
|
||||
};
|
||||
|
||||
return reply.send({
|
||||
folder: folderResponse,
|
||||
message: "Folder updated successfully.",
|
||||
});
|
||||
} catch (error: any) {
|
||||
console.error("Error in updateFolder:", error);
|
||||
return reply.status(400).send({ error: error.message });
|
||||
}
|
||||
}
|
||||
|
||||
async moveFolder(request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
await request.jwtVerify();
|
||||
const userId = (request as any).user?.userId;
|
||||
|
||||
if (!userId) {
|
||||
return reply.status(401).send({ error: "Unauthorized: a valid token is required to access this resource." });
|
||||
}
|
||||
|
||||
const { id } = request.params as { id: string };
|
||||
const body = request.body as any;
|
||||
|
||||
const input = {
|
||||
parentId: body.parentId === undefined ? null : body.parentId,
|
||||
};
|
||||
|
||||
const validatedInput = MoveFolderSchema.parse(input);
|
||||
|
||||
const existingFolder = await prisma.folder.findFirst({
|
||||
where: { id, userId },
|
||||
});
|
||||
|
||||
if (!existingFolder) {
|
||||
return reply.status(404).send({ error: "Folder not found." });
|
||||
}
|
||||
|
||||
if (validatedInput.parentId) {
|
||||
const parentFolder = await prisma.folder.findFirst({
|
||||
where: { id: validatedInput.parentId, userId },
|
||||
});
|
||||
if (!parentFolder) {
|
||||
return reply.status(400).send({ error: "Parent folder not found or access denied" });
|
||||
}
|
||||
|
||||
if (await this.isDescendantOf(validatedInput.parentId, id, userId)) {
|
||||
return reply.status(400).send({ error: "Cannot move a folder into itself or its subfolders" });
|
||||
}
|
||||
}
|
||||
|
||||
const updatedFolder = await prisma.folder.update({
|
||||
where: { id },
|
||||
data: { parentId: validatedInput.parentId },
|
||||
include: {
|
||||
_count: {
|
||||
select: {
|
||||
files: true,
|
||||
children: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const totalSize = await this.folderService.calculateFolderSize(updatedFolder.id, userId);
|
||||
|
||||
const folderResponse = {
|
||||
id: updatedFolder.id,
|
||||
name: updatedFolder.name,
|
||||
description: updatedFolder.description,
|
||||
objectName: updatedFolder.objectName,
|
||||
parentId: updatedFolder.parentId,
|
||||
userId: updatedFolder.userId,
|
||||
createdAt: updatedFolder.createdAt,
|
||||
updatedAt: updatedFolder.updatedAt,
|
||||
totalSize: totalSize.toString(),
|
||||
_count: updatedFolder._count,
|
||||
};
|
||||
|
||||
return reply.send({
|
||||
folder: folderResponse,
|
||||
message: "Folder moved successfully.",
|
||||
});
|
||||
} catch (error: any) {
|
||||
console.error("Error in moveFolder:", error);
|
||||
const statusCode = error.message === "Folder not found" ? 404 : 400;
|
||||
return reply.status(statusCode).send({ error: error.message });
|
||||
}
|
||||
}
|
||||
|
||||
async deleteFolder(request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
await request.jwtVerify();
|
||||
const { id } = request.params as { id: string };
|
||||
if (!id) {
|
||||
return reply.status(400).send({ error: "The 'id' parameter is required." });
|
||||
}
|
||||
|
||||
const folderRecord = await prisma.folder.findUnique({ where: { id } });
|
||||
if (!folderRecord) {
|
||||
return reply.status(404).send({ error: "Folder not found." });
|
||||
}
|
||||
|
||||
const userId = (request as any).user?.userId;
|
||||
if (folderRecord.userId !== userId) {
|
||||
return reply.status(403).send({ error: "Access denied." });
|
||||
}
|
||||
|
||||
await this.folderService.deleteObject(folderRecord.objectName);
|
||||
|
||||
await prisma.folder.delete({ where: { id } });
|
||||
|
||||
return reply.send({ message: "Folder deleted successfully." });
|
||||
} catch (error) {
|
||||
console.error("Error in deleteFolder:", error);
|
||||
return reply.status(500).send({ error: "Internal server error." });
|
||||
}
|
||||
}
|
||||
|
||||
private async isDescendantOf(potentialDescendantId: string, ancestorId: string, userId: string): Promise<boolean> {
|
||||
let currentId: string | null = potentialDescendantId;
|
||||
|
||||
while (currentId) {
|
||||
if (currentId === ancestorId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const folder: { parentId: string | null } | null = await prisma.folder.findFirst({
|
||||
where: { id: currentId, userId },
|
||||
});
|
||||
|
||||
if (!folder) break;
|
||||
currentId = folder.parentId;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
56
apps/server/src/modules/folder/dto.ts
Normal file
56
apps/server/src/modules/folder/dto.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const RegisterFolderSchema = z.object({
|
||||
name: z.string().min(1, "O nome da pasta é obrigatório"),
|
||||
description: z.string().optional(),
|
||||
objectName: z.string().min(1, "O objectName é obrigatório"),
|
||||
parentId: z.string().optional(),
|
||||
});
|
||||
|
||||
export const UpdateFolderSchema = z.object({
|
||||
name: z.string().optional(),
|
||||
description: z.string().optional().nullable(),
|
||||
});
|
||||
|
||||
export const MoveFolderSchema = z.object({
|
||||
parentId: z.string().nullable(),
|
||||
});
|
||||
|
||||
export const FolderResponseSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
description: z.string().nullable(),
|
||||
parentId: z.string().nullable(),
|
||||
userId: z.string(),
|
||||
createdAt: z.date(),
|
||||
updatedAt: z.date(),
|
||||
totalSize: z
|
||||
.bigint()
|
||||
.transform((val) => val.toString())
|
||||
.optional(),
|
||||
_count: z
|
||||
.object({
|
||||
files: z.number(),
|
||||
children: z.number(),
|
||||
})
|
||||
.optional(),
|
||||
});
|
||||
|
||||
export const CheckFolderSchema = z.object({
|
||||
name: z.string().min(1, "O nome da pasta é obrigatório"),
|
||||
description: z.string().optional(),
|
||||
objectName: z.string().min(1, "O objectName é obrigatório"),
|
||||
parentId: z.string().optional(),
|
||||
});
|
||||
|
||||
export const ListFoldersSchema = z.object({
|
||||
parentId: z.string().optional(),
|
||||
recursive: z.string().optional().default("true"),
|
||||
});
|
||||
|
||||
export type RegisterFolderInput = z.infer<typeof RegisterFolderSchema>;
|
||||
export type UpdateFolderInput = z.infer<typeof UpdateFolderSchema>;
|
||||
export type MoveFolderInput = z.infer<typeof MoveFolderSchema>;
|
||||
export type CheckFolderInput = z.infer<typeof CheckFolderSchema>;
|
||||
export type ListFoldersInput = z.infer<typeof ListFoldersSchema>;
|
||||
export type FolderResponse = z.infer<typeof FolderResponseSchema>;
|
245
apps/server/src/modules/folder/routes.ts
Normal file
245
apps/server/src/modules/folder/routes.ts
Normal file
@@ -0,0 +1,245 @@
|
||||
import { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";
|
||||
import { z } from "zod";
|
||||
|
||||
import { FolderController } from "./controller";
|
||||
import {
|
||||
CheckFolderSchema,
|
||||
FolderResponseSchema,
|
||||
ListFoldersSchema,
|
||||
MoveFolderSchema,
|
||||
RegisterFolderSchema,
|
||||
UpdateFolderSchema,
|
||||
} from "./dto";
|
||||
|
||||
export async function folderRoutes(app: FastifyInstance) {
|
||||
const folderController = new FolderController();
|
||||
|
||||
const preValidation = async (request: FastifyRequest, reply: FastifyReply) => {
|
||||
try {
|
||||
await request.jwtVerify();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
reply.status(401).send({ error: "Token inválido ou ausente." });
|
||||
}
|
||||
};
|
||||
|
||||
app.post(
|
||||
"/folders",
|
||||
{
|
||||
schema: {
|
||||
tags: ["Folder"],
|
||||
operationId: "registerFolder",
|
||||
summary: "Register Folder Metadata",
|
||||
description: "Registers folder metadata in the database",
|
||||
body: RegisterFolderSchema,
|
||||
response: {
|
||||
201: z.object({
|
||||
folder: z.object({
|
||||
id: z.string().describe("The folder ID"),
|
||||
name: z.string().describe("The folder name"),
|
||||
description: z.string().nullable().describe("The folder description"),
|
||||
parentId: z.string().nullable().describe("The parent folder ID"),
|
||||
userId: z.string().describe("The user ID"),
|
||||
createdAt: z.date().describe("The folder creation date"),
|
||||
updatedAt: z.date().describe("The folder last update date"),
|
||||
totalSize: z.string().optional().describe("The total size of the folder"),
|
||||
_count: z
|
||||
.object({
|
||||
files: z.number().describe("Number of files in folder"),
|
||||
children: z.number().describe("Number of subfolders"),
|
||||
})
|
||||
.optional()
|
||||
.describe("Count statistics"),
|
||||
}),
|
||||
message: z.string().describe("The folder registration message"),
|
||||
}),
|
||||
400: z.object({ error: z.string().describe("Error message") }),
|
||||
401: z.object({ error: z.string().describe("Error message") }),
|
||||
},
|
||||
},
|
||||
},
|
||||
folderController.registerFolder.bind(folderController)
|
||||
);
|
||||
|
||||
app.post(
|
||||
"/folders/check",
|
||||
{
|
||||
preValidation,
|
||||
schema: {
|
||||
tags: ["Folder"],
|
||||
operationId: "checkFolder",
|
||||
summary: "Check Folder validity",
|
||||
description: "Checks if the folder meets all requirements",
|
||||
body: CheckFolderSchema,
|
||||
response: {
|
||||
201: z.object({
|
||||
message: z.string().describe("The folder check success message"),
|
||||
}),
|
||||
400: z.object({
|
||||
error: z.string().describe("Error message"),
|
||||
code: z.string().optional().describe("Error code"),
|
||||
details: z.string().optional().describe("Error details"),
|
||||
}),
|
||||
401: z.object({
|
||||
error: z.string().describe("Error message"),
|
||||
code: z.string().optional().describe("Error code"),
|
||||
}),
|
||||
},
|
||||
},
|
||||
},
|
||||
folderController.checkFolder.bind(folderController)
|
||||
);
|
||||
|
||||
app.get(
|
||||
"/folders",
|
||||
{
|
||||
preValidation,
|
||||
schema: {
|
||||
tags: ["Folder"],
|
||||
operationId: "listFolders",
|
||||
summary: "List Folders",
|
||||
description: "Lists user folders recursively by default, optionally filtered by folder",
|
||||
querystring: ListFoldersSchema,
|
||||
response: {
|
||||
200: z.object({
|
||||
folders: z.array(
|
||||
z.object({
|
||||
id: z.string().describe("The folder ID"),
|
||||
name: z.string().describe("The folder name"),
|
||||
description: z.string().nullable().describe("The folder description"),
|
||||
parentId: z.string().nullable().describe("The parent folder ID"),
|
||||
userId: z.string().describe("The user ID"),
|
||||
createdAt: z.date().describe("The folder creation date"),
|
||||
updatedAt: z.date().describe("The folder last update date"),
|
||||
totalSize: z.string().optional().describe("The total size of the folder"),
|
||||
_count: z
|
||||
.object({
|
||||
files: z.number().describe("Number of files in folder"),
|
||||
children: z.number().describe("Number of subfolders"),
|
||||
})
|
||||
.optional()
|
||||
.describe("Count statistics"),
|
||||
})
|
||||
),
|
||||
}),
|
||||
500: z.object({ error: z.string().describe("Error message") }),
|
||||
},
|
||||
},
|
||||
},
|
||||
folderController.listFolders.bind(folderController)
|
||||
);
|
||||
|
||||
app.patch(
|
||||
"/folders/:id",
|
||||
{
|
||||
preValidation,
|
||||
schema: {
|
||||
tags: ["Folder"],
|
||||
operationId: "updateFolder",
|
||||
summary: "Update Folder Metadata",
|
||||
description: "Updates folder metadata in the database",
|
||||
params: z.object({
|
||||
id: z.string().min(1, "The folder id is required").describe("The folder ID"),
|
||||
}),
|
||||
body: UpdateFolderSchema,
|
||||
response: {
|
||||
200: z.object({
|
||||
folder: z.object({
|
||||
id: z.string().describe("The folder ID"),
|
||||
name: z.string().describe("The folder name"),
|
||||
description: z.string().nullable().describe("The folder description"),
|
||||
parentId: z.string().nullable().describe("The parent folder ID"),
|
||||
userId: z.string().describe("The user ID"),
|
||||
createdAt: z.date().describe("The folder creation date"),
|
||||
updatedAt: z.date().describe("The folder last update date"),
|
||||
totalSize: z.string().optional().describe("The total size of the folder"),
|
||||
_count: z
|
||||
.object({
|
||||
files: z.number().describe("Number of files in folder"),
|
||||
children: z.number().describe("Number of subfolders"),
|
||||
})
|
||||
.optional()
|
||||
.describe("Count statistics"),
|
||||
}),
|
||||
message: z.string().describe("Success message"),
|
||||
}),
|
||||
400: z.object({ error: z.string().describe("Error message") }),
|
||||
401: z.object({ error: z.string().describe("Error message") }),
|
||||
403: z.object({ error: z.string().describe("Error message") }),
|
||||
404: z.object({ error: z.string().describe("Error message") }),
|
||||
},
|
||||
},
|
||||
},
|
||||
folderController.updateFolder.bind(folderController)
|
||||
);
|
||||
|
||||
app.put(
|
||||
"/folders/:id/move",
|
||||
{
|
||||
preValidation,
|
||||
schema: {
|
||||
tags: ["Folder"],
|
||||
operationId: "moveFolder",
|
||||
summary: "Move Folder",
|
||||
description: "Moves a folder to a different parent folder",
|
||||
params: z.object({
|
||||
id: z.string().min(1, "The folder id is required").describe("The folder ID"),
|
||||
}),
|
||||
body: MoveFolderSchema,
|
||||
response: {
|
||||
200: z.object({
|
||||
folder: z.object({
|
||||
id: z.string().describe("The folder ID"),
|
||||
name: z.string().describe("The folder name"),
|
||||
description: z.string().nullable().describe("The folder description"),
|
||||
parentId: z.string().nullable().describe("The parent folder ID"),
|
||||
userId: z.string().describe("The user ID"),
|
||||
createdAt: z.date().describe("The folder creation date"),
|
||||
updatedAt: z.date().describe("The folder last update date"),
|
||||
totalSize: z.string().optional().describe("The total size of the folder"),
|
||||
_count: z
|
||||
.object({
|
||||
files: z.number().describe("Number of files in folder"),
|
||||
children: z.number().describe("Number of subfolders"),
|
||||
})
|
||||
.optional()
|
||||
.describe("Count statistics"),
|
||||
}),
|
||||
message: z.string().describe("Success message"),
|
||||
}),
|
||||
400: z.object({ error: z.string().describe("Error message") }),
|
||||
401: z.object({ error: z.string().describe("Error message") }),
|
||||
403: z.object({ error: z.string().describe("Error message") }),
|
||||
404: z.object({ error: z.string().describe("Error message") }),
|
||||
},
|
||||
},
|
||||
},
|
||||
folderController.moveFolder.bind(folderController)
|
||||
);
|
||||
|
||||
app.delete(
|
||||
"/folders/:id",
|
||||
{
|
||||
preValidation,
|
||||
schema: {
|
||||
tags: ["Folder"],
|
||||
operationId: "deleteFolder",
|
||||
summary: "Delete Folder",
|
||||
description: "Deletes a folder and all its contents",
|
||||
params: z.object({
|
||||
id: z.string().min(1, "The folder id is required").describe("The folder ID"),
|
||||
}),
|
||||
response: {
|
||||
200: z.object({
|
||||
message: z.string().describe("The folder deletion message"),
|
||||
}),
|
||||
400: z.object({ error: z.string().describe("Error message") }),
|
||||
401: z.object({ error: z.string().describe("Error message") }),
|
||||
404: z.object({ error: z.string().describe("Error message") }),
|
||||
500: z.object({ error: z.string().describe("Error message") }),
|
||||
},
|
||||
},
|
||||
},
|
||||
folderController.deleteFolder.bind(folderController)
|
||||
);
|
||||
}
|
93
apps/server/src/modules/folder/service.ts
Normal file
93
apps/server/src/modules/folder/service.ts
Normal file
@@ -0,0 +1,93 @@
|
||||
import { isS3Enabled } from "../../config/storage.config";
|
||||
import { FilesystemStorageProvider } from "../../providers/filesystem-storage.provider";
|
||||
import { S3StorageProvider } from "../../providers/s3-storage.provider";
|
||||
import { prisma } from "../../shared/prisma";
|
||||
import { StorageProvider } from "../../types/storage";
|
||||
|
||||
export class FolderService {
|
||||
private storageProvider: StorageProvider;
|
||||
|
||||
constructor() {
|
||||
if (isS3Enabled) {
|
||||
this.storageProvider = new S3StorageProvider();
|
||||
} else {
|
||||
this.storageProvider = FilesystemStorageProvider.getInstance();
|
||||
}
|
||||
}
|
||||
|
||||
async getPresignedPutUrl(objectName: string, expires: number): Promise<string> {
|
||||
try {
|
||||
return await this.storageProvider.getPresignedPutUrl(objectName, expires);
|
||||
} catch (err) {
|
||||
console.error("Erro no presignedPutObject:", err);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
async getPresignedGetUrl(objectName: string, expires: number, folderName?: string): Promise<string> {
|
||||
try {
|
||||
return await this.storageProvider.getPresignedGetUrl(objectName, expires, folderName);
|
||||
} catch (err) {
|
||||
console.error("Erro no presignedGetObject:", err);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
async deleteObject(objectName: string): Promise<void> {
|
||||
try {
|
||||
await this.storageProvider.deleteObject(objectName);
|
||||
} catch (err) {
|
||||
console.error("Erro no removeObject:", err);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
isFilesystemMode(): boolean {
|
||||
return !isS3Enabled;
|
||||
}
|
||||
|
||||
async getAllFilesInFolder(folderId: string, userId: string, basePath: string = ""): Promise<any[]> {
|
||||
const files = await prisma.file.findMany({
|
||||
where: { folderId, userId },
|
||||
});
|
||||
|
||||
const subfolders = await prisma.folder.findMany({
|
||||
where: { parentId: folderId, userId },
|
||||
select: { id: true, name: true },
|
||||
});
|
||||
|
||||
let allFiles = files.map((file: any) => ({
|
||||
...file,
|
||||
relativePath: basePath + file.name,
|
||||
}));
|
||||
|
||||
for (const subfolder of subfolders) {
|
||||
const subfolderPath = basePath + subfolder.name + "/";
|
||||
const subfolderFiles = await this.getAllFilesInFolder(subfolder.id, userId, subfolderPath);
|
||||
allFiles = [...allFiles, ...subfolderFiles];
|
||||
}
|
||||
|
||||
return allFiles;
|
||||
}
|
||||
|
||||
async calculateFolderSize(folderId: string, userId: string): Promise<bigint> {
|
||||
const files = await prisma.file.findMany({
|
||||
where: { folderId, userId },
|
||||
select: { size: true },
|
||||
});
|
||||
|
||||
const subfolders = await prisma.folder.findMany({
|
||||
where: { parentId: folderId, userId },
|
||||
select: { id: true },
|
||||
});
|
||||
|
||||
let totalSize = files.reduce((sum, file) => sum + file.size, BigInt(0));
|
||||
|
||||
for (const subfolder of subfolders) {
|
||||
const subfolderSize = await this.calculateFolderSize(subfolder.id, userId);
|
||||
totalSize += subfolderSize;
|
||||
}
|
||||
|
||||
return totalSize;
|
||||
}
|
||||
}
|
@@ -318,8 +318,60 @@ export class ReverseShareController {
|
||||
}
|
||||
|
||||
const { fileId } = request.params as { fileId: string };
|
||||
const result = await this.reverseShareService.downloadReverseShareFile(fileId, userId);
|
||||
return reply.send(result);
|
||||
|
||||
const fileInfo = await this.reverseShareService.getFileInfo(fileId, userId);
|
||||
const downloadId = `reverse-${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;
|
||||
|
||||
const { DownloadMemoryManager } = await import("../../utils/download-memory-manager.js");
|
||||
const memoryManager = DownloadMemoryManager.getInstance();
|
||||
|
||||
const fileSizeMB = Number(fileInfo.size) / (1024 * 1024);
|
||||
console.log(
|
||||
`[REVERSE-DOWNLOAD] Requesting slot for ${downloadId}: ${fileInfo.name} (${fileSizeMB.toFixed(1)}MB)`
|
||||
);
|
||||
|
||||
try {
|
||||
await memoryManager.requestDownloadSlot(downloadId, {
|
||||
fileName: fileInfo.name,
|
||||
fileSize: Number(fileInfo.size),
|
||||
objectName: fileInfo.objectName,
|
||||
});
|
||||
} catch (error: any) {
|
||||
console.warn(`[REVERSE-DOWNLOAD] Queued ${downloadId}: ${error.message}`);
|
||||
return reply.status(202).send({
|
||||
queued: true,
|
||||
downloadId: downloadId,
|
||||
message: "Download queued due to memory constraints",
|
||||
estimatedWaitTime: error.estimatedWaitTime || 60,
|
||||
});
|
||||
}
|
||||
|
||||
console.log(`[REVERSE-DOWNLOAD] Starting ${downloadId}: ${fileInfo.name} (${fileSizeMB.toFixed(1)}MB)`);
|
||||
memoryManager.startDownload(downloadId);
|
||||
|
||||
try {
|
||||
const result = await this.reverseShareService.downloadReverseShareFile(fileId, userId);
|
||||
|
||||
const originalUrl = result.url;
|
||||
reply.header("X-Download-ID", downloadId);
|
||||
|
||||
reply.raw.on("finish", () => {
|
||||
memoryManager.endDownload(downloadId);
|
||||
});
|
||||
|
||||
reply.raw.on("close", () => {
|
||||
memoryManager.endDownload(downloadId);
|
||||
});
|
||||
|
||||
reply.raw.on("error", () => {
|
||||
memoryManager.endDownload(downloadId);
|
||||
});
|
||||
|
||||
return reply.send(result);
|
||||
} catch (downloadError) {
|
||||
memoryManager.endDownload(downloadId);
|
||||
throw downloadError;
|
||||
}
|
||||
} catch (error: any) {
|
||||
if (error.message === "File not found") {
|
||||
return reply.status(404).send({ error: error.message });
|
||||
@@ -484,4 +536,17 @@ export class ReverseShareController {
|
||||
return reply.status(500).send({ error: "Internal server error" });
|
||||
}
|
||||
}
|
||||
|
||||
async getReverseShareMetadataByAlias(request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
const { alias } = request.params as { alias: string };
|
||||
const metadata = await this.reverseShareService.getReverseShareMetadataByAlias(alias);
|
||||
return reply.send(metadata);
|
||||
} catch (error: any) {
|
||||
if (error.message === "Reverse share not found") {
|
||||
return reply.status(404).send({ error: error.message });
|
||||
}
|
||||
return reply.status(400).send({ error: error.message });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -401,6 +401,12 @@ export async function reverseShareRoutes(app: FastifyInstance) {
|
||||
url: z.string().describe("Presigned download URL - expires after 1 hour"),
|
||||
expiresIn: z.number().describe("URL expiration time in seconds (3600 = 1 hour)"),
|
||||
}),
|
||||
202: z.object({
|
||||
queued: z.boolean().describe("Download was queued due to memory constraints"),
|
||||
downloadId: z.string().describe("Download identifier for tracking"),
|
||||
message: z.string().describe("Queue status message"),
|
||||
estimatedWaitTime: z.number().describe("Estimated wait time in seconds"),
|
||||
}),
|
||||
401: z.object({ error: z.string() }),
|
||||
404: z.object({ error: z.string() }),
|
||||
},
|
||||
@@ -586,4 +592,32 @@ export async function reverseShareRoutes(app: FastifyInstance) {
|
||||
},
|
||||
reverseShareController.copyFileToUserFiles.bind(reverseShareController)
|
||||
);
|
||||
|
||||
app.get(
|
||||
"/reverse-shares/alias/:alias/metadata",
|
||||
{
|
||||
schema: {
|
||||
tags: ["Reverse Share"],
|
||||
operationId: "getReverseShareMetadataByAlias",
|
||||
summary: "Get reverse share metadata by alias for Open Graph",
|
||||
description: "Get lightweight metadata for a reverse share by alias, used for social media previews",
|
||||
params: z.object({
|
||||
alias: z.string().describe("Alias of the reverse share"),
|
||||
}),
|
||||
response: {
|
||||
200: z.object({
|
||||
name: z.string().nullable(),
|
||||
description: z.string().nullable(),
|
||||
totalFiles: z.number(),
|
||||
hasPassword: z.boolean(),
|
||||
isExpired: z.boolean(),
|
||||
isInactive: z.boolean(),
|
||||
maxFiles: z.number().nullable(),
|
||||
}),
|
||||
404: z.object({ error: z.string() }),
|
||||
},
|
||||
},
|
||||
},
|
||||
reverseShareController.getReverseShareMetadataByAlias.bind(reverseShareController)
|
||||
);
|
||||
}
|
||||
|
@@ -227,7 +227,7 @@ export class ReverseShareService {
|
||||
}
|
||||
}
|
||||
|
||||
const expires = 3600; // 1 hour
|
||||
const expires = parseInt(env.PRESIGNED_URL_EXPIRATION);
|
||||
const url = await this.fileService.getPresignedPutUrl(objectName, expires);
|
||||
|
||||
return { url, expiresIn: expires };
|
||||
@@ -257,7 +257,7 @@ export class ReverseShareService {
|
||||
}
|
||||
}
|
||||
|
||||
const expires = 3600; // 1 hour
|
||||
const expires = parseInt(env.PRESIGNED_URL_EXPIRATION);
|
||||
const url = await this.fileService.getPresignedPutUrl(objectName, expires);
|
||||
|
||||
return { url, expiresIn: expires };
|
||||
@@ -367,6 +367,25 @@ export class ReverseShareService {
|
||||
return this.formatFileResponse(file);
|
||||
}
|
||||
|
||||
async getFileInfo(fileId: string, creatorId: string) {
|
||||
const file = await this.reverseShareRepository.findFileById(fileId);
|
||||
if (!file) {
|
||||
throw new Error("File not found");
|
||||
}
|
||||
|
||||
if (file.reverseShare.creatorId !== creatorId) {
|
||||
throw new Error("Unauthorized to access this file");
|
||||
}
|
||||
|
||||
return {
|
||||
id: file.id,
|
||||
name: file.name,
|
||||
size: file.size,
|
||||
objectName: file.objectName,
|
||||
extension: file.extension,
|
||||
};
|
||||
}
|
||||
|
||||
async downloadReverseShareFile(fileId: string, creatorId: string) {
|
||||
const file = await this.reverseShareRepository.findFileById(fileId);
|
||||
if (!file) {
|
||||
@@ -378,7 +397,7 @@ export class ReverseShareService {
|
||||
}
|
||||
|
||||
const fileName = file.name;
|
||||
const expires = 3600; // 1 hour
|
||||
const expires = parseInt(env.PRESIGNED_URL_EXPIRATION);
|
||||
const url = await this.fileService.getPresignedGetUrl(file.objectName, expires, fileName);
|
||||
return { url, expiresIn: expires };
|
||||
}
|
||||
@@ -533,17 +552,7 @@ export class ReverseShareService {
|
||||
throw new Error(`File size exceeds the maximum allowed size of ${maxSizeMB}MB`);
|
||||
}
|
||||
|
||||
// Check if DEMO_MODE is enabled
|
||||
const isDemoMode = env.DEMO_MODE === "true";
|
||||
|
||||
let maxTotalStorage: bigint;
|
||||
if (isDemoMode) {
|
||||
// In demo mode, limit all users to 200MB
|
||||
maxTotalStorage = BigInt(200 * 1024 * 1024); // 200MB in bytes
|
||||
} else {
|
||||
// Normal behavior - use maxTotalStoragePerUser configuration
|
||||
maxTotalStorage = BigInt(await configService.getValue("maxTotalStoragePerUser"));
|
||||
}
|
||||
const maxTotalStorage = BigInt(await configService.getValue("maxTotalStoragePerUser"));
|
||||
|
||||
const userFiles = await prisma.file.findMany({
|
||||
where: { userId: creatorId },
|
||||
@@ -764,4 +773,30 @@ export class ReverseShareService {
|
||||
updatedAt: file.updatedAt.toISOString(),
|
||||
};
|
||||
}
|
||||
|
||||
async getReverseShareMetadataByAlias(alias: string) {
|
||||
const reverseShare = await this.reverseShareRepository.findByAlias(alias);
|
||||
if (!reverseShare) {
|
||||
throw new Error("Reverse share not found");
|
||||
}
|
||||
|
||||
// Check if reverse share is expired
|
||||
const isExpired = reverseShare.expiration && new Date(reverseShare.expiration) < new Date();
|
||||
|
||||
// Check if inactive
|
||||
const isInactive = !reverseShare.isActive;
|
||||
|
||||
const totalFiles = reverseShare.files?.length || 0;
|
||||
const hasPassword = !!reverseShare.password;
|
||||
|
||||
return {
|
||||
name: reverseShare.name,
|
||||
description: reverseShare.description,
|
||||
totalFiles,
|
||||
hasPassword,
|
||||
isExpired,
|
||||
isInactive,
|
||||
maxFiles: reverseShare.maxFiles,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@ import { FastifyReply, FastifyRequest } from "fastify";
|
||||
|
||||
import {
|
||||
CreateShareSchema,
|
||||
UpdateShareFilesSchema,
|
||||
UpdateShareItemsSchema,
|
||||
UpdateSharePasswordSchema,
|
||||
UpdateShareRecipientsSchema,
|
||||
UpdateShareSchema,
|
||||
@@ -116,7 +116,7 @@ export class ShareController {
|
||||
}
|
||||
}
|
||||
|
||||
async addFiles(request: FastifyRequest, reply: FastifyReply) {
|
||||
async addItems(request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
await request.jwtVerify();
|
||||
const userId = (request as any).user?.userId;
|
||||
@@ -125,9 +125,9 @@ export class ShareController {
|
||||
}
|
||||
|
||||
const { shareId } = request.params as { shareId: string };
|
||||
const { files } = UpdateShareFilesSchema.parse(request.body);
|
||||
const { files, folders } = UpdateShareItemsSchema.parse(request.body);
|
||||
|
||||
const share = await this.shareService.addFilesToShare(shareId, userId, files);
|
||||
const share = await this.shareService.addItemsToShare(shareId, userId, files || [], folders || []);
|
||||
return reply.send({ share });
|
||||
} catch (error: any) {
|
||||
if (error.message === "Share not found") {
|
||||
@@ -136,14 +136,14 @@ export class ShareController {
|
||||
if (error.message === "Unauthorized to update this share") {
|
||||
return reply.status(401).send({ error: error.message });
|
||||
}
|
||||
if (error.message.startsWith("Files not found:")) {
|
||||
if (error.message.startsWith("Files not found:") || error.message.startsWith("Folders not found:")) {
|
||||
return reply.status(404).send({ error: error.message });
|
||||
}
|
||||
return reply.status(400).send({ error: error.message });
|
||||
}
|
||||
}
|
||||
|
||||
async removeFiles(request: FastifyRequest, reply: FastifyReply) {
|
||||
async removeItems(request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
await request.jwtVerify();
|
||||
const userId = (request as any).user?.userId;
|
||||
@@ -152,9 +152,9 @@ export class ShareController {
|
||||
}
|
||||
|
||||
const { shareId } = request.params as { shareId: string };
|
||||
const { files } = UpdateShareFilesSchema.parse(request.body);
|
||||
const { files, folders } = UpdateShareItemsSchema.parse(request.body);
|
||||
|
||||
const share = await this.shareService.removeFilesFromShare(shareId, userId, files);
|
||||
const share = await this.shareService.removeItemsFromShare(shareId, userId, files || [], folders || []);
|
||||
return reply.send({ share });
|
||||
} catch (error: any) {
|
||||
if (error.message === "Share not found") {
|
||||
@@ -295,4 +295,17 @@ export class ShareController {
|
||||
return reply.status(400).send({ error: error.message });
|
||||
}
|
||||
}
|
||||
|
||||
async getShareMetadataByAlias(request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
const { alias } = request.params as { alias: string };
|
||||
const metadata = await this.shareService.getShareMetadataByAlias(alias);
|
||||
return reply.send(metadata);
|
||||
} catch (error: any) {
|
||||
if (error.message === "Share not found") {
|
||||
return reply.status(404).send({ error: error.message });
|
||||
}
|
||||
return reply.status(400).send({ error: error.message });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,19 +1,31 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const CreateShareSchema = z.object({
|
||||
name: z.string().optional().describe("The share name"),
|
||||
description: z.string().optional().describe("The share description"),
|
||||
expiration: z
|
||||
.string()
|
||||
.datetime({
|
||||
message: "Data de expiração deve estar no formato ISO 8601 (ex: 2025-02-06T13:20:49Z)",
|
||||
})
|
||||
.optional(),
|
||||
files: z.array(z.string()).describe("The file IDs"),
|
||||
password: z.string().optional().describe("The share password"),
|
||||
maxViews: z.number().optional().nullable().describe("The maximum number of views"),
|
||||
recipients: z.array(z.string().email()).optional().describe("The recipient emails"),
|
||||
});
|
||||
export const CreateShareSchema = z
|
||||
.object({
|
||||
name: z.string().optional().describe("The share name"),
|
||||
description: z.string().optional().describe("The share description"),
|
||||
expiration: z
|
||||
.string()
|
||||
.datetime({
|
||||
message: "Data de expiração deve estar no formato ISO 8601 (ex: 2025-02-06T13:20:49Z)",
|
||||
})
|
||||
.optional(),
|
||||
files: z.array(z.string()).optional().describe("The file IDs"),
|
||||
folders: z.array(z.string()).optional().describe("The folder IDs"),
|
||||
password: z.string().optional().describe("The share password"),
|
||||
maxViews: z.number().optional().nullable().describe("The maximum number of views"),
|
||||
recipients: z.array(z.string().email()).optional().describe("The recipient emails"),
|
||||
})
|
||||
.refine(
|
||||
(data) => {
|
||||
const hasFiles = data.files && data.files.length > 0;
|
||||
const hasFolders = data.folders && data.folders.length > 0;
|
||||
return hasFiles || hasFolders;
|
||||
},
|
||||
{
|
||||
message: "At least one file or folder must be selected to create a share",
|
||||
}
|
||||
);
|
||||
|
||||
export const UpdateShareSchema = z.object({
|
||||
id: z.string(),
|
||||
@@ -55,10 +67,30 @@ export const ShareResponseSchema = z.object({
|
||||
size: z.string().describe("The file size"),
|
||||
objectName: z.string().describe("The file object name"),
|
||||
userId: z.string().describe("The user ID"),
|
||||
folderId: z.string().nullable().describe("The folder ID containing this file"),
|
||||
createdAt: z.string().describe("The file creation date"),
|
||||
updatedAt: z.string().describe("The file update date"),
|
||||
})
|
||||
),
|
||||
folders: z.array(
|
||||
z.object({
|
||||
id: z.string().describe("The folder ID"),
|
||||
name: z.string().describe("The folder name"),
|
||||
description: z.string().nullable().describe("The folder description"),
|
||||
objectName: z.string().describe("The folder object name"),
|
||||
parentId: z.string().nullable().describe("The parent folder ID"),
|
||||
userId: z.string().describe("The user ID"),
|
||||
totalSize: z.string().nullable().describe("The total size of folder contents"),
|
||||
createdAt: z.string().describe("The folder creation date"),
|
||||
updatedAt: z.string().describe("The folder update date"),
|
||||
_count: z
|
||||
.object({
|
||||
files: z.number().describe("Number of files in folder"),
|
||||
children: z.number().describe("Number of subfolders"),
|
||||
})
|
||||
.optional(),
|
||||
})
|
||||
),
|
||||
recipients: z.array(
|
||||
z.object({
|
||||
id: z.string().describe("The recipient ID"),
|
||||
@@ -74,9 +106,21 @@ export const UpdateSharePasswordSchema = z.object({
|
||||
password: z.string().nullable().describe("The new password. Send null to remove password"),
|
||||
});
|
||||
|
||||
export const UpdateShareFilesSchema = z.object({
|
||||
files: z.array(z.string().min(1, "File ID is required").describe("The file IDs")),
|
||||
});
|
||||
export const UpdateShareItemsSchema = z
|
||||
.object({
|
||||
files: z.array(z.string().min(1, "File ID is required").describe("The file IDs")).optional(),
|
||||
folders: z.array(z.string().min(1, "Folder ID is required").describe("The folder IDs")).optional(),
|
||||
})
|
||||
.refine(
|
||||
(data) => {
|
||||
const hasFiles = data.files && data.files.length > 0;
|
||||
const hasFolders = data.folders && data.folders.length > 0;
|
||||
return hasFiles || hasFolders;
|
||||
},
|
||||
{
|
||||
message: "At least one file or folder must be provided",
|
||||
}
|
||||
);
|
||||
|
||||
export const UpdateShareRecipientsSchema = z.object({
|
||||
emails: z.array(z.string().email("Invalid email format").describe("The recipient emails")),
|
||||
|
@@ -9,30 +9,42 @@ export interface IShareRepository {
|
||||
| (Share & {
|
||||
security: ShareSecurity;
|
||||
files: any[];
|
||||
folders: any[];
|
||||
recipients: { email: string }[];
|
||||
})
|
||||
| null
|
||||
>;
|
||||
findShareBySecurityId(securityId: string): Promise<(Share & { security: ShareSecurity; files: any[] }) | null>;
|
||||
findShareBySecurityId(
|
||||
securityId: string
|
||||
): Promise<(Share & { security: ShareSecurity; files: any[]; folders: any[] }) | null>;
|
||||
findShareByAlias(
|
||||
alias: string
|
||||
): Promise<(Share & { security: ShareSecurity; files: any[]; folders: any[]; recipients: any[] }) | null>;
|
||||
updateShare(id: string, data: Partial<Share>): Promise<Share>;
|
||||
updateShareSecurity(id: string, data: Partial<ShareSecurity>): Promise<ShareSecurity>;
|
||||
deleteShare(id: string): Promise<Share>;
|
||||
incrementViews(id: string): Promise<Share>;
|
||||
addFilesToShare(shareId: string, fileIds: string[]): Promise<void>;
|
||||
removeFilesFromShare(shareId: string, fileIds: string[]): Promise<void>;
|
||||
addFoldersToShare(shareId: string, folderIds: string[]): Promise<void>;
|
||||
removeFoldersFromShare(shareId: string, folderIds: string[]): Promise<void>;
|
||||
findFilesByIds(fileIds: string[]): Promise<any[]>;
|
||||
findFoldersByIds(folderIds: string[]): Promise<any[]>;
|
||||
addRecipients(shareId: string, emails: string[]): Promise<void>;
|
||||
removeRecipients(shareId: string, emails: string[]): Promise<void>;
|
||||
findSharesByUserId(userId: string): Promise<Share[]>;
|
||||
findSharesByUserId(
|
||||
userId: string
|
||||
): Promise<(Share & { security: ShareSecurity; files: any[]; folders: any[]; recipients: any[]; alias: any })[]>;
|
||||
}
|
||||
|
||||
export class PrismaShareRepository implements IShareRepository {
|
||||
async createShare(
|
||||
data: Omit<CreateShareInput, "password" | "maxViews"> & { securityId: string; creatorId: string }
|
||||
): Promise<Share> {
|
||||
const { files, recipients, expiration, ...shareData } = data;
|
||||
const { files, folders, recipients, expiration, ...shareData } = data;
|
||||
|
||||
const validFiles = (files ?? []).filter((id) => id && id.trim().length > 0);
|
||||
const validFolders = (folders ?? []).filter((id) => id && id.trim().length > 0);
|
||||
const validRecipients = (recipients ?? []).filter((email) => email && email.trim().length > 0);
|
||||
|
||||
return prisma.share.create({
|
||||
@@ -45,6 +57,12 @@ export class PrismaShareRepository implements IShareRepository {
|
||||
connect: validFiles.map((id) => ({ id })),
|
||||
}
|
||||
: undefined,
|
||||
folders:
|
||||
validFolders.length > 0
|
||||
? {
|
||||
connect: validFolders.map((id) => ({ id })),
|
||||
}
|
||||
: undefined,
|
||||
recipients:
|
||||
validRecipients?.length > 0
|
||||
? {
|
||||
@@ -61,10 +79,28 @@ export class PrismaShareRepository implements IShareRepository {
|
||||
return prisma.share.findUnique({
|
||||
where: { id },
|
||||
include: {
|
||||
alias: true,
|
||||
security: true,
|
||||
files: true,
|
||||
folders: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
description: true,
|
||||
objectName: true,
|
||||
parentId: true,
|
||||
userId: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
_count: {
|
||||
select: {
|
||||
files: true,
|
||||
children: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
recipients: true,
|
||||
alias: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -75,10 +111,63 @@ export class PrismaShareRepository implements IShareRepository {
|
||||
include: {
|
||||
security: true,
|
||||
files: true,
|
||||
folders: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
description: true,
|
||||
objectName: true,
|
||||
parentId: true,
|
||||
userId: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
_count: {
|
||||
select: {
|
||||
files: true,
|
||||
children: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async findShareByAlias(alias: string) {
|
||||
const shareAlias = await prisma.shareAlias.findUnique({
|
||||
where: { alias },
|
||||
include: {
|
||||
share: {
|
||||
include: {
|
||||
security: true,
|
||||
files: true,
|
||||
folders: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
description: true,
|
||||
objectName: true,
|
||||
parentId: true,
|
||||
userId: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
_count: {
|
||||
select: {
|
||||
files: true,
|
||||
children: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
recipients: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return shareAlias?.share || null;
|
||||
}
|
||||
|
||||
async updateShare(id: string, data: Partial<Share>): Promise<Share> {
|
||||
return prisma.share.update({
|
||||
where: { id },
|
||||
@@ -121,6 +210,17 @@ export class PrismaShareRepository implements IShareRepository {
|
||||
});
|
||||
}
|
||||
|
||||
async addFoldersToShare(shareId: string, folderIds: string[]): Promise<void> {
|
||||
await prisma.share.update({
|
||||
where: { id: shareId },
|
||||
data: {
|
||||
folders: {
|
||||
connect: folderIds.map((id) => ({ id })),
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async removeFilesFromShare(shareId: string, fileIds: string[]): Promise<void> {
|
||||
await prisma.share.update({
|
||||
where: { id: shareId },
|
||||
@@ -132,6 +232,17 @@ export class PrismaShareRepository implements IShareRepository {
|
||||
});
|
||||
}
|
||||
|
||||
async removeFoldersFromShare(shareId: string, folderIds: string[]): Promise<void> {
|
||||
await prisma.share.update({
|
||||
where: { id: shareId },
|
||||
data: {
|
||||
folders: {
|
||||
disconnect: folderIds.map((id) => ({ id })),
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async findFilesByIds(fileIds: string[]): Promise<any[]> {
|
||||
return prisma.file.findMany({
|
||||
where: {
|
||||
@@ -142,6 +253,16 @@ export class PrismaShareRepository implements IShareRepository {
|
||||
});
|
||||
}
|
||||
|
||||
async findFoldersByIds(folderIds: string[]): Promise<any[]> {
|
||||
return prisma.folder.findMany({
|
||||
where: {
|
||||
id: {
|
||||
in: folderIds,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async addRecipients(shareId: string, emails: string[]): Promise<void> {
|
||||
await prisma.share.update({
|
||||
where: { id: shareId },
|
||||
@@ -178,6 +299,24 @@ export class PrismaShareRepository implements IShareRepository {
|
||||
include: {
|
||||
security: true,
|
||||
files: true,
|
||||
folders: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
description: true,
|
||||
objectName: true,
|
||||
parentId: true,
|
||||
userId: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
_count: {
|
||||
select: {
|
||||
files: true,
|
||||
children: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
recipients: true,
|
||||
alias: true,
|
||||
},
|
||||
|
@@ -6,7 +6,7 @@ import {
|
||||
CreateShareSchema,
|
||||
ShareAliasResponseSchema,
|
||||
ShareResponseSchema,
|
||||
UpdateShareFilesSchema,
|
||||
UpdateShareItemsSchema,
|
||||
UpdateSharePasswordSchema,
|
||||
UpdateShareRecipientsSchema,
|
||||
UpdateShareSchema,
|
||||
@@ -32,7 +32,7 @@ export async function shareRoutes(app: FastifyInstance) {
|
||||
tags: ["Share"],
|
||||
operationId: "createShare",
|
||||
summary: "Create a new share",
|
||||
description: "Create a new share",
|
||||
description: "Create a new share with files and/or folders",
|
||||
body: CreateShareSchema,
|
||||
response: {
|
||||
201: z.object({
|
||||
@@ -164,17 +164,17 @@ export async function shareRoutes(app: FastifyInstance) {
|
||||
);
|
||||
|
||||
app.post(
|
||||
"/shares/:shareId/files",
|
||||
"/shares/:shareId/items",
|
||||
{
|
||||
preValidation,
|
||||
schema: {
|
||||
tags: ["Share"],
|
||||
operationId: "addFiles",
|
||||
summary: "Add files to share",
|
||||
operationId: "addItems",
|
||||
summary: "Add files and/or folders to share",
|
||||
params: z.object({
|
||||
shareId: z.string().describe("The share ID"),
|
||||
}),
|
||||
body: UpdateShareFilesSchema,
|
||||
body: UpdateShareItemsSchema,
|
||||
response: {
|
||||
200: z.object({
|
||||
share: ShareResponseSchema,
|
||||
@@ -185,21 +185,21 @@ export async function shareRoutes(app: FastifyInstance) {
|
||||
},
|
||||
},
|
||||
},
|
||||
shareController.addFiles.bind(shareController)
|
||||
shareController.addItems.bind(shareController)
|
||||
);
|
||||
|
||||
app.delete(
|
||||
"/shares/:shareId/files",
|
||||
"/shares/:shareId/items",
|
||||
{
|
||||
preValidation,
|
||||
schema: {
|
||||
tags: ["Share"],
|
||||
operationId: "removeFiles",
|
||||
summary: "Remove files from share",
|
||||
operationId: "removeItems",
|
||||
summary: "Remove files and/or folders from share",
|
||||
params: z.object({
|
||||
shareId: z.string().describe("The share ID"),
|
||||
}),
|
||||
body: UpdateShareFilesSchema,
|
||||
body: UpdateShareItemsSchema,
|
||||
response: {
|
||||
200: z.object({
|
||||
share: ShareResponseSchema,
|
||||
@@ -210,7 +210,7 @@ export async function shareRoutes(app: FastifyInstance) {
|
||||
},
|
||||
},
|
||||
},
|
||||
shareController.removeFiles.bind(shareController)
|
||||
shareController.removeItems.bind(shareController)
|
||||
);
|
||||
|
||||
app.post(
|
||||
@@ -347,4 +347,32 @@ export async function shareRoutes(app: FastifyInstance) {
|
||||
},
|
||||
shareController.notifyRecipients.bind(shareController)
|
||||
);
|
||||
|
||||
app.get(
|
||||
"/shares/alias/:alias/metadata",
|
||||
{
|
||||
schema: {
|
||||
tags: ["Share"],
|
||||
operationId: "getShareMetadataByAlias",
|
||||
summary: "Get share metadata by alias for Open Graph",
|
||||
description: "Get lightweight metadata for a share by alias, used for social media previews",
|
||||
params: z.object({
|
||||
alias: z.string().describe("The share alias"),
|
||||
}),
|
||||
response: {
|
||||
200: z.object({
|
||||
name: z.string().nullable(),
|
||||
description: z.string().nullable(),
|
||||
totalFiles: z.number(),
|
||||
totalFolders: z.number(),
|
||||
hasPassword: z.boolean(),
|
||||
isExpired: z.boolean(),
|
||||
isMaxViewsReached: z.boolean(),
|
||||
}),
|
||||
404: z.object({ error: z.string() }),
|
||||
},
|
||||
},
|
||||
},
|
||||
shareController.getShareMetadataByAlias.bind(shareController)
|
||||
);
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@ import bcrypt from "bcryptjs";
|
||||
|
||||
import { prisma } from "../../shared/prisma";
|
||||
import { EmailService } from "../email/service";
|
||||
import { FolderService } from "../folder/service";
|
||||
import { UserService } from "../user/service";
|
||||
import { CreateShareInput, ShareResponseSchema, UpdateShareInput } from "./dto";
|
||||
import { IShareRepository, PrismaShareRepository } from "./repository";
|
||||
@@ -11,8 +12,9 @@ export class ShareService {
|
||||
|
||||
private emailService = new EmailService();
|
||||
private userService = new UserService();
|
||||
private folderService = new FolderService();
|
||||
|
||||
private formatShareResponse(share: any) {
|
||||
private async formatShareResponse(share: any) {
|
||||
return {
|
||||
...share,
|
||||
createdAt: share.createdAt.toISOString(),
|
||||
@@ -36,6 +38,20 @@ export class ShareService {
|
||||
createdAt: file.createdAt.toISOString(),
|
||||
updatedAt: file.updatedAt.toISOString(),
|
||||
})) || [],
|
||||
folders:
|
||||
share.folders && share.folders.length > 0
|
||||
? await Promise.all(
|
||||
share.folders.map(async (folder: any) => {
|
||||
const totalSize = await this.folderService.calculateFolderSize(folder.id, folder.userId);
|
||||
return {
|
||||
...folder,
|
||||
totalSize: totalSize.toString(),
|
||||
createdAt: folder.createdAt.toISOString(),
|
||||
updatedAt: folder.updatedAt.toISOString(),
|
||||
};
|
||||
})
|
||||
)
|
||||
: [],
|
||||
recipients:
|
||||
share.recipients?.map((recipient: any) => ({
|
||||
...recipient,
|
||||
@@ -46,7 +62,37 @@ export class ShareService {
|
||||
}
|
||||
|
||||
async createShare(data: CreateShareInput, userId: string) {
|
||||
const { password, maxViews, ...shareData } = data;
|
||||
const { password, maxViews, files, folders, ...shareData } = data;
|
||||
|
||||
if (files && files.length > 0) {
|
||||
const existingFiles = await prisma.file.findMany({
|
||||
where: {
|
||||
id: { in: files },
|
||||
userId: userId,
|
||||
},
|
||||
});
|
||||
const notFoundFiles = files.filter((id) => !existingFiles.some((file) => file.id === id));
|
||||
if (notFoundFiles.length > 0) {
|
||||
throw new Error(`Files not found or access denied: ${notFoundFiles.join(", ")}`);
|
||||
}
|
||||
}
|
||||
|
||||
if (folders && folders.length > 0) {
|
||||
const existingFolders = await prisma.folder.findMany({
|
||||
where: {
|
||||
id: { in: folders },
|
||||
userId: userId,
|
||||
},
|
||||
});
|
||||
const notFoundFolders = folders.filter((id) => !existingFolders.some((folder) => folder.id === id));
|
||||
if (notFoundFolders.length > 0) {
|
||||
throw new Error(`Folders not found or access denied: ${notFoundFolders.join(", ")}`);
|
||||
}
|
||||
}
|
||||
|
||||
if ((!files || files.length === 0) && (!folders || folders.length === 0)) {
|
||||
throw new Error("At least one file or folder must be selected to create a share");
|
||||
}
|
||||
|
||||
const security = await prisma.shareSecurity.create({
|
||||
data: {
|
||||
@@ -57,12 +103,14 @@ export class ShareService {
|
||||
|
||||
const share = await this.shareRepository.createShare({
|
||||
...shareData,
|
||||
files,
|
||||
folders,
|
||||
securityId: security.id,
|
||||
creatorId: userId,
|
||||
});
|
||||
|
||||
const shareWithRelations = await this.shareRepository.findShareById(share.id);
|
||||
return ShareResponseSchema.parse(this.formatShareResponse(shareWithRelations));
|
||||
return ShareResponseSchema.parse(await this.formatShareResponse(shareWithRelations));
|
||||
}
|
||||
|
||||
async getShare(shareId: string, password?: string, userId?: string) {
|
||||
@@ -73,7 +121,7 @@ export class ShareService {
|
||||
}
|
||||
|
||||
if (userId && share.creatorId === userId) {
|
||||
return ShareResponseSchema.parse(this.formatShareResponse(share));
|
||||
return ShareResponseSchema.parse(await this.formatShareResponse(share));
|
||||
}
|
||||
|
||||
if (share.expiration && new Date() > new Date(share.expiration)) {
|
||||
@@ -98,7 +146,7 @@ export class ShareService {
|
||||
await this.shareRepository.incrementViews(shareId);
|
||||
|
||||
const updatedShare = await this.shareRepository.findShareById(shareId);
|
||||
return ShareResponseSchema.parse(this.formatShareResponse(updatedShare));
|
||||
return ShareResponseSchema.parse(await this.formatShareResponse(updatedShare));
|
||||
}
|
||||
|
||||
async updateShare(shareId: string, data: Omit<UpdateShareInput, "id">, userId: string) {
|
||||
@@ -136,7 +184,7 @@ export class ShareService {
|
||||
});
|
||||
const shareWithRelations = await this.shareRepository.findShareById(shareId);
|
||||
|
||||
return this.formatShareResponse(shareWithRelations);
|
||||
return await this.formatShareResponse(shareWithRelations);
|
||||
}
|
||||
|
||||
async deleteShare(id: string) {
|
||||
@@ -172,12 +220,12 @@ export class ShareService {
|
||||
return deletedShare;
|
||||
});
|
||||
|
||||
return ShareResponseSchema.parse(this.formatShareResponse(deleted));
|
||||
return ShareResponseSchema.parse(await this.formatShareResponse(deleted));
|
||||
}
|
||||
|
||||
async listUserShares(userId: string) {
|
||||
const shares = await this.shareRepository.findSharesByUserId(userId);
|
||||
return shares.map((share) => this.formatShareResponse(share));
|
||||
return await Promise.all(shares.map(async (share) => await this.formatShareResponse(share)));
|
||||
}
|
||||
|
||||
async updateSharePassword(shareId: string, userId: string, password: string | null) {
|
||||
@@ -195,10 +243,10 @@ export class ShareService {
|
||||
});
|
||||
|
||||
const updated = await this.shareRepository.findShareById(shareId);
|
||||
return ShareResponseSchema.parse(this.formatShareResponse(updated));
|
||||
return ShareResponseSchema.parse(await this.formatShareResponse(updated));
|
||||
}
|
||||
|
||||
async addFilesToShare(shareId: string, userId: string, fileIds: string[]) {
|
||||
async addItemsToShare(shareId: string, userId: string, fileIds: string[], folderIds: string[]) {
|
||||
const share = await this.shareRepository.findShareById(shareId);
|
||||
if (!share) {
|
||||
throw new Error("Share not found");
|
||||
@@ -208,19 +256,33 @@ export class ShareService {
|
||||
throw new Error("Unauthorized to update this share");
|
||||
}
|
||||
|
||||
const existingFiles = await this.shareRepository.findFilesByIds(fileIds);
|
||||
const notFoundFiles = fileIds.filter((id) => !existingFiles.some((file) => file.id === id));
|
||||
if (fileIds.length > 0) {
|
||||
const existingFiles = await this.shareRepository.findFilesByIds(fileIds);
|
||||
const notFoundFiles = fileIds.filter((id) => !existingFiles.some((file) => file.id === id));
|
||||
|
||||
if (notFoundFiles.length > 0) {
|
||||
throw new Error(`Files not found: ${notFoundFiles.join(", ")}`);
|
||||
if (notFoundFiles.length > 0) {
|
||||
throw new Error(`Files not found: ${notFoundFiles.join(", ")}`);
|
||||
}
|
||||
|
||||
await this.shareRepository.addFilesToShare(shareId, fileIds);
|
||||
}
|
||||
|
||||
if (folderIds.length > 0) {
|
||||
const existingFolders = await this.shareRepository.findFoldersByIds(folderIds);
|
||||
const notFoundFolders = folderIds.filter((id) => !existingFolders.some((folder) => folder.id === id));
|
||||
|
||||
if (notFoundFolders.length > 0) {
|
||||
throw new Error(`Folders not found: ${notFoundFolders.join(", ")}`);
|
||||
}
|
||||
|
||||
await this.shareRepository.addFoldersToShare(shareId, folderIds);
|
||||
}
|
||||
|
||||
await this.shareRepository.addFilesToShare(shareId, fileIds);
|
||||
const updated = await this.shareRepository.findShareById(shareId);
|
||||
return ShareResponseSchema.parse(this.formatShareResponse(updated));
|
||||
return ShareResponseSchema.parse(await this.formatShareResponse(updated));
|
||||
}
|
||||
|
||||
async removeFilesFromShare(shareId: string, userId: string, fileIds: string[]) {
|
||||
async removeItemsFromShare(shareId: string, userId: string, fileIds: string[], folderIds: string[]) {
|
||||
const share = await this.shareRepository.findShareById(shareId);
|
||||
if (!share) {
|
||||
throw new Error("Share not found");
|
||||
@@ -230,9 +292,16 @@ export class ShareService {
|
||||
throw new Error("Unauthorized to update this share");
|
||||
}
|
||||
|
||||
await this.shareRepository.removeFilesFromShare(shareId, fileIds);
|
||||
if (fileIds.length > 0) {
|
||||
await this.shareRepository.removeFilesFromShare(shareId, fileIds);
|
||||
}
|
||||
|
||||
if (folderIds.length > 0) {
|
||||
await this.shareRepository.removeFoldersFromShare(shareId, folderIds);
|
||||
}
|
||||
|
||||
const updated = await this.shareRepository.findShareById(shareId);
|
||||
return ShareResponseSchema.parse(this.formatShareResponse(updated));
|
||||
return ShareResponseSchema.parse(await this.formatShareResponse(updated));
|
||||
}
|
||||
|
||||
async findShareById(id: string) {
|
||||
@@ -255,7 +324,7 @@ export class ShareService {
|
||||
|
||||
await this.shareRepository.addRecipients(shareId, emails);
|
||||
const updated = await this.shareRepository.findShareById(shareId);
|
||||
return ShareResponseSchema.parse(this.formatShareResponse(updated));
|
||||
return ShareResponseSchema.parse(await this.formatShareResponse(updated));
|
||||
}
|
||||
|
||||
async removeRecipients(shareId: string, userId: string, emails: string[]) {
|
||||
@@ -270,7 +339,7 @@ export class ShareService {
|
||||
|
||||
await this.shareRepository.removeRecipients(shareId, emails);
|
||||
const updated = await this.shareRepository.findShareById(shareId);
|
||||
return ShareResponseSchema.parse(this.formatShareResponse(updated));
|
||||
return ShareResponseSchema.parse(await this.formatShareResponse(updated));
|
||||
}
|
||||
|
||||
async createOrUpdateAlias(shareId: string, alias: string, userId: string) {
|
||||
@@ -341,7 +410,6 @@ export class ShareService {
|
||||
throw new Error("No recipients found for this share");
|
||||
}
|
||||
|
||||
// Get sender information
|
||||
let senderName = "Someone";
|
||||
try {
|
||||
const sender = await this.userService.getUserById(userId);
|
||||
@@ -372,4 +440,31 @@ export class ShareService {
|
||||
notifiedRecipients,
|
||||
};
|
||||
}
|
||||
|
||||
async getShareMetadataByAlias(alias: string) {
|
||||
const share = await this.shareRepository.findShareByAlias(alias);
|
||||
if (!share) {
|
||||
throw new Error("Share not found");
|
||||
}
|
||||
|
||||
// Check if share is expired
|
||||
const isExpired = share.expiration && new Date(share.expiration) < new Date();
|
||||
|
||||
// Check if max views reached
|
||||
const isMaxViewsReached = share.security.maxViews !== null && share.views >= share.security.maxViews;
|
||||
|
||||
const totalFiles = share.files?.length || 0;
|
||||
const totalFolders = share.folders?.length || 0;
|
||||
const hasPassword = !!share.security.password;
|
||||
|
||||
return {
|
||||
name: share.name,
|
||||
description: share.description,
|
||||
totalFiles,
|
||||
totalFolders,
|
||||
hasPassword,
|
||||
isExpired,
|
||||
isMaxViewsReached,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -284,7 +284,7 @@ export class StorageService {
|
||||
private async _getDiskSpaceMultiplePaths(): Promise<{ total: number; available: number } | null> {
|
||||
const basePaths = IS_RUNNING_IN_CONTAINER
|
||||
? ["/app/server/uploads", "/app/server/temp-uploads", "/app/server/temp-chunks", "/app/server", "/app", "/"]
|
||||
: [".", "./uploads", process.cwd()];
|
||||
: [env.CUSTOM_PATH || ".", "./uploads", process.cwd()];
|
||||
|
||||
const synologyPaths = await this._detectSynologyVolumes();
|
||||
|
||||
@@ -324,89 +324,45 @@ export class StorageService {
|
||||
uploadAllowed: boolean;
|
||||
}> {
|
||||
try {
|
||||
const isDemoMode = env.DEMO_MODE === "true";
|
||||
|
||||
if (isAdmin) {
|
||||
if (isDemoMode) {
|
||||
const demoMaxStorage = 200 * 1024 * 1024;
|
||||
const demoMaxStorageGB = this._ensureNumber(demoMaxStorage / (1024 * 1024 * 1024), 0);
|
||||
const diskInfo = await this._getDiskSpaceMultiplePaths();
|
||||
|
||||
const userFiles = await prisma.file.findMany({
|
||||
where: { userId },
|
||||
select: { size: true },
|
||||
});
|
||||
|
||||
const totalUsedStorage = userFiles.reduce((acc, file) => acc + file.size, BigInt(0));
|
||||
const usedStorageGB = this._ensureNumber(Number(totalUsedStorage) / (1024 * 1024 * 1024), 0);
|
||||
const availableStorageGB = this._ensureNumber(demoMaxStorageGB - usedStorageGB, 0);
|
||||
|
||||
return {
|
||||
diskSizeGB: Number(demoMaxStorageGB.toFixed(2)),
|
||||
diskUsedGB: Number(usedStorageGB.toFixed(2)),
|
||||
diskAvailableGB: Number(availableStorageGB.toFixed(2)),
|
||||
uploadAllowed: availableStorageGB > 0,
|
||||
};
|
||||
} else {
|
||||
const diskInfo = await this._getDiskSpaceMultiplePaths();
|
||||
|
||||
if (!diskInfo) {
|
||||
throw new Error("Unable to determine actual disk space - system configuration issue");
|
||||
}
|
||||
|
||||
const { total, available } = diskInfo;
|
||||
const used = total - available;
|
||||
|
||||
const diskSizeGB = this._ensureNumber(total / (1024 * 1024 * 1024), 0);
|
||||
const diskUsedGB = this._ensureNumber(used / (1024 * 1024 * 1024), 0);
|
||||
const diskAvailableGB = this._ensureNumber(available / (1024 * 1024 * 1024), 0);
|
||||
|
||||
return {
|
||||
diskSizeGB: Number(diskSizeGB.toFixed(2)),
|
||||
diskUsedGB: Number(diskUsedGB.toFixed(2)),
|
||||
diskAvailableGB: Number(diskAvailableGB.toFixed(2)),
|
||||
uploadAllowed: diskAvailableGB > 0.1,
|
||||
};
|
||||
if (!diskInfo) {
|
||||
throw new Error("Unable to determine actual disk space - system configuration issue");
|
||||
}
|
||||
|
||||
const { total, available } = diskInfo;
|
||||
const used = total - available;
|
||||
|
||||
const diskSizeGB = this._ensureNumber(total / (1024 * 1024 * 1024), 0);
|
||||
const diskUsedGB = this._ensureNumber(used / (1024 * 1024 * 1024), 0);
|
||||
const diskAvailableGB = this._ensureNumber(available / (1024 * 1024 * 1024), 0);
|
||||
|
||||
return {
|
||||
diskSizeGB: Number(diskSizeGB.toFixed(2)),
|
||||
diskUsedGB: Number(diskUsedGB.toFixed(2)),
|
||||
diskAvailableGB: Number(diskAvailableGB.toFixed(2)),
|
||||
uploadAllowed: diskAvailableGB > 0.1,
|
||||
};
|
||||
} else if (userId) {
|
||||
if (isDemoMode) {
|
||||
const demoMaxStorage = 200 * 1024 * 1024;
|
||||
const demoMaxStorageGB = this._ensureNumber(demoMaxStorage / (1024 * 1024 * 1024), 0);
|
||||
const maxTotalStorage = BigInt(await this.configService.getValue("maxTotalStoragePerUser"));
|
||||
const maxStorageGB = this._ensureNumber(Number(maxTotalStorage) / (1024 * 1024 * 1024), 10);
|
||||
|
||||
const userFiles = await prisma.file.findMany({
|
||||
where: { userId },
|
||||
select: { size: true },
|
||||
});
|
||||
const userFiles = await prisma.file.findMany({
|
||||
where: { userId },
|
||||
select: { size: true },
|
||||
});
|
||||
|
||||
const totalUsedStorage = userFiles.reduce((acc, file) => acc + file.size, BigInt(0));
|
||||
const usedStorageGB = this._ensureNumber(Number(totalUsedStorage) / (1024 * 1024 * 1024), 0);
|
||||
const availableStorageGB = this._ensureNumber(demoMaxStorageGB - usedStorageGB, 0);
|
||||
const totalUsedStorage = userFiles.reduce((acc, file) => acc + file.size, BigInt(0));
|
||||
const usedStorageGB = this._ensureNumber(Number(totalUsedStorage) / (1024 * 1024 * 1024), 0);
|
||||
const availableStorageGB = this._ensureNumber(maxStorageGB - usedStorageGB, 0);
|
||||
|
||||
return {
|
||||
diskSizeGB: Number(demoMaxStorageGB.toFixed(2)),
|
||||
diskUsedGB: Number(usedStorageGB.toFixed(2)),
|
||||
diskAvailableGB: Number(availableStorageGB.toFixed(2)),
|
||||
uploadAllowed: availableStorageGB > 0,
|
||||
};
|
||||
} else {
|
||||
const maxTotalStorage = BigInt(await this.configService.getValue("maxTotalStoragePerUser"));
|
||||
const maxStorageGB = this._ensureNumber(Number(maxTotalStorage) / (1024 * 1024 * 1024), 10);
|
||||
|
||||
const userFiles = await prisma.file.findMany({
|
||||
where: { userId },
|
||||
select: { size: true },
|
||||
});
|
||||
|
||||
const totalUsedStorage = userFiles.reduce((acc, file) => acc + file.size, BigInt(0));
|
||||
const usedStorageGB = this._ensureNumber(Number(totalUsedStorage) / (1024 * 1024 * 1024), 0);
|
||||
const availableStorageGB = this._ensureNumber(maxStorageGB - usedStorageGB, 0);
|
||||
|
||||
return {
|
||||
diskSizeGB: Number(maxStorageGB.toFixed(2)),
|
||||
diskUsedGB: Number(usedStorageGB.toFixed(2)),
|
||||
diskAvailableGB: Number(availableStorageGB.toFixed(2)),
|
||||
uploadAllowed: availableStorageGB > 0,
|
||||
};
|
||||
}
|
||||
return {
|
||||
diskSizeGB: Number(maxStorageGB.toFixed(2)),
|
||||
diskUsedGB: Number(usedStorageGB.toFixed(2)),
|
||||
diskAvailableGB: Number(availableStorageGB.toFixed(2)),
|
||||
uploadAllowed: availableStorageGB > 0,
|
||||
};
|
||||
}
|
||||
|
||||
throw new Error("User ID is required for non-admin users");
|
||||
|
@@ -80,7 +80,8 @@ export class FilesystemStorageProvider implements StorageProvider {
|
||||
public createEncryptStream(): Transform {
|
||||
if (this.isEncryptionDisabled) {
|
||||
return new Transform({
|
||||
transform(chunk, encoding, callback) {
|
||||
highWaterMark: 64 * 1024,
|
||||
transform(chunk, _encoding, callback) {
|
||||
this.push(chunk);
|
||||
callback();
|
||||
},
|
||||
@@ -94,7 +95,8 @@ export class FilesystemStorageProvider implements StorageProvider {
|
||||
let isFirstChunk = true;
|
||||
|
||||
return new Transform({
|
||||
transform(chunk, encoding, callback) {
|
||||
highWaterMark: 64 * 1024,
|
||||
transform(chunk, _encoding, callback) {
|
||||
try {
|
||||
if (isFirstChunk) {
|
||||
this.push(iv);
|
||||
@@ -124,7 +126,8 @@ export class FilesystemStorageProvider implements StorageProvider {
|
||||
public createDecryptStream(): Transform {
|
||||
if (this.isEncryptionDisabled) {
|
||||
return new Transform({
|
||||
transform(chunk, encoding, callback) {
|
||||
highWaterMark: 64 * 1024,
|
||||
transform(chunk, _encoding, callback) {
|
||||
this.push(chunk);
|
||||
callback();
|
||||
},
|
||||
@@ -137,15 +140,16 @@ export class FilesystemStorageProvider implements StorageProvider {
|
||||
let ivBuffer = Buffer.alloc(0);
|
||||
|
||||
return new Transform({
|
||||
transform(chunk, encoding, callback) {
|
||||
highWaterMark: 64 * 1024,
|
||||
transform(chunk, _encoding, callback) {
|
||||
try {
|
||||
if (!iv) {
|
||||
ivBuffer = Buffer.concat([ivBuffer, chunk]);
|
||||
|
||||
if (ivBuffer.length >= 16) {
|
||||
iv = ivBuffer.slice(0, 16);
|
||||
iv = ivBuffer.subarray(0, 16);
|
||||
decipher = crypto.createDecipheriv("aes-256-cbc", key, iv);
|
||||
const remainingData = ivBuffer.slice(16);
|
||||
const remainingData = ivBuffer.subarray(16);
|
||||
if (remainingData.length > 0) {
|
||||
const decrypted = decipher.update(remainingData);
|
||||
this.push(decrypted);
|
||||
@@ -188,13 +192,9 @@ export class FilesystemStorageProvider implements StorageProvider {
|
||||
return `/api/filesystem/upload/${token}`;
|
||||
}
|
||||
|
||||
async getPresignedGetUrl(objectName: string, expires: number, fileName?: string): Promise<string> {
|
||||
const token = crypto.randomBytes(32).toString("hex");
|
||||
const expiresAt = Date.now() + expires * 1000;
|
||||
|
||||
this.downloadTokens.set(token, { objectName, expiresAt, fileName });
|
||||
|
||||
return `/api/filesystem/download/${token}`;
|
||||
async getPresignedGetUrl(objectName: string): Promise<string> {
|
||||
const encodedObjectName = encodeURIComponent(objectName);
|
||||
return `/api/files/download?objectName=${encodedObjectName}`;
|
||||
}
|
||||
|
||||
async deleteObject(objectName: string): Promise<void> {
|
||||
@@ -236,7 +236,7 @@ export class FilesystemStorageProvider implements StorageProvider {
|
||||
|
||||
try {
|
||||
await pipeline(inputStream, encryptStream, writeStream);
|
||||
await fs.rename(tempPath, filePath);
|
||||
await this.moveFile(tempPath, filePath);
|
||||
} catch (error) {
|
||||
await this.cleanupTempFile(tempPath);
|
||||
throw error;
|
||||
@@ -267,31 +267,35 @@ export class FilesystemStorageProvider implements StorageProvider {
|
||||
|
||||
createDownloadStream(objectName: string): NodeJS.ReadableStream {
|
||||
const filePath = this.getFilePath(objectName);
|
||||
const fileStream = fsSync.createReadStream(filePath);
|
||||
|
||||
const streamOptions = {
|
||||
highWaterMark: 64 * 1024,
|
||||
autoDestroy: true,
|
||||
emitClose: true,
|
||||
};
|
||||
|
||||
const fileStream = fsSync.createReadStream(filePath, streamOptions);
|
||||
|
||||
if (this.isEncryptionDisabled) {
|
||||
fileStream.on("end", () => {
|
||||
if (global.gc) {
|
||||
global.gc();
|
||||
}
|
||||
});
|
||||
|
||||
fileStream.on("close", () => {
|
||||
if (global.gc) {
|
||||
global.gc();
|
||||
}
|
||||
});
|
||||
|
||||
this.setupStreamMemoryManagement(fileStream, objectName);
|
||||
return fileStream;
|
||||
}
|
||||
|
||||
const decryptStream = this.createDecryptStream();
|
||||
const { PassThrough } = require("stream");
|
||||
const outputStream = new PassThrough(streamOptions);
|
||||
|
||||
let isDestroyed = false;
|
||||
let memoryCheckInterval: NodeJS.Timeout;
|
||||
|
||||
const cleanup = () => {
|
||||
if (isDestroyed) return;
|
||||
isDestroyed = true;
|
||||
|
||||
if (memoryCheckInterval) {
|
||||
clearInterval(memoryCheckInterval);
|
||||
}
|
||||
|
||||
try {
|
||||
if (fileStream && !fileStream.destroyed) {
|
||||
fileStream.destroy();
|
||||
@@ -299,28 +303,104 @@ export class FilesystemStorageProvider implements StorageProvider {
|
||||
if (decryptStream && !decryptStream.destroyed) {
|
||||
decryptStream.destroy();
|
||||
}
|
||||
if (outputStream && !outputStream.destroyed) {
|
||||
outputStream.destroy();
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn("Error during download stream cleanup:", error);
|
||||
}
|
||||
|
||||
if (global.gc) {
|
||||
global.gc();
|
||||
}
|
||||
setImmediate(() => {
|
||||
if (global.gc) {
|
||||
global.gc();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
fileStream.on("error", cleanup);
|
||||
decryptStream.on("error", cleanup);
|
||||
decryptStream.on("end", cleanup);
|
||||
decryptStream.on("close", cleanup);
|
||||
memoryCheckInterval = setInterval(() => {
|
||||
const memUsage = process.memoryUsage();
|
||||
const memoryUsageMB = memUsage.heapUsed / 1024 / 1024;
|
||||
|
||||
decryptStream.on("pipe", (src: any) => {
|
||||
if (memoryUsageMB > 1024) {
|
||||
if (!fileStream.readableFlowing) return;
|
||||
|
||||
console.warn(
|
||||
`[MEMORY THROTTLE] ${objectName} - Pausing stream due to high memory usage: ${memoryUsageMB.toFixed(2)}MB`
|
||||
);
|
||||
fileStream.pause();
|
||||
|
||||
if (global.gc) {
|
||||
global.gc();
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
if (!isDestroyed && fileStream && !fileStream.destroyed) {
|
||||
fileStream.resume();
|
||||
console.log(`[MEMORY THROTTLE] ${objectName} - Stream resumed`);
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
fileStream.on("error", (error: any) => {
|
||||
console.error("File stream error:", error);
|
||||
cleanup();
|
||||
});
|
||||
|
||||
decryptStream.on("error", (error: any) => {
|
||||
console.error("Decrypt stream error:", error);
|
||||
cleanup();
|
||||
});
|
||||
|
||||
outputStream.on("error", (error: any) => {
|
||||
console.error("Output stream error:", error);
|
||||
cleanup();
|
||||
});
|
||||
|
||||
outputStream.on("close", cleanup);
|
||||
outputStream.on("finish", cleanup);
|
||||
|
||||
outputStream.on("pipe", (src: any) => {
|
||||
if (src && src.on) {
|
||||
src.on("close", cleanup);
|
||||
src.on("error", cleanup);
|
||||
}
|
||||
});
|
||||
|
||||
return fileStream.pipe(decryptStream);
|
||||
pipeline(fileStream, decryptStream, outputStream)
|
||||
.then(() => {})
|
||||
.catch((error: any) => {
|
||||
console.error("Pipeline error during download:", error);
|
||||
cleanup();
|
||||
});
|
||||
|
||||
this.setupStreamMemoryManagement(outputStream, objectName);
|
||||
return outputStream;
|
||||
}
|
||||
|
||||
private setupStreamMemoryManagement(stream: NodeJS.ReadableStream, objectName: string): void {
|
||||
let lastMemoryLog = 0;
|
||||
|
||||
stream.on("data", () => {
|
||||
const now = Date.now();
|
||||
if (now - lastMemoryLog > 30000) {
|
||||
FilesystemStorageProvider.logMemoryUsage(`Active download: ${objectName}`);
|
||||
lastMemoryLog = now;
|
||||
}
|
||||
});
|
||||
|
||||
stream.on("end", () => {
|
||||
FilesystemStorageProvider.logMemoryUsage(`Download completed: ${objectName}`);
|
||||
setImmediate(() => {
|
||||
if (global.gc) {
|
||||
global.gc();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
stream.on("close", () => {
|
||||
FilesystemStorageProvider.logMemoryUsage(`Download closed: ${objectName}`);
|
||||
});
|
||||
}
|
||||
|
||||
async createDownloadRangeStream(objectName: string, start: number, end: number): Promise<NodeJS.ReadableStream> {
|
||||
@@ -552,13 +632,8 @@ export class FilesystemStorageProvider implements StorageProvider {
|
||||
return { objectName: data.objectName, fileName: data.fileName };
|
||||
}
|
||||
|
||||
consumeUploadToken(token: string): void {
|
||||
this.uploadTokens.delete(token);
|
||||
}
|
||||
|
||||
consumeDownloadToken(token: string): void {
|
||||
this.downloadTokens.delete(token);
|
||||
}
|
||||
// Tokens are automatically cleaned up by cleanExpiredTokens() every 5 minutes
|
||||
// No need to manually consume tokens - allows reuse for previews, range requests, etc.
|
||||
|
||||
private async cleanupTempFile(tempPath: string): Promise<void> {
|
||||
try {
|
||||
@@ -623,4 +698,18 @@ export class FilesystemStorageProvider implements StorageProvider {
|
||||
console.error("Error during temp directory cleanup:", error);
|
||||
}
|
||||
}
|
||||
|
||||
private async moveFile(src: string, dest: string): Promise<void> {
|
||||
try {
|
||||
await fs.rename(src, dest);
|
||||
} catch (err: any) {
|
||||
if (err.code === "EXDEV") {
|
||||
// cross-device: fallback to copy + delete
|
||||
await fs.copyFile(src, dest);
|
||||
await fs.unlink(src);
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,8 +1,9 @@
|
||||
import { DeleteObjectCommand, GetObjectCommand, PutObjectCommand } from "@aws-sdk/client-s3";
|
||||
import { DeleteObjectCommand, GetObjectCommand, HeadObjectCommand, PutObjectCommand } from "@aws-sdk/client-s3";
|
||||
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
|
||||
|
||||
import { bucketName, s3Client } from "../config/storage.config";
|
||||
import { StorageProvider } from "../types/storage";
|
||||
import { getContentType } from "../utils/mime-types";
|
||||
|
||||
export class S3StorageProvider implements StorageProvider {
|
||||
constructor() {
|
||||
@@ -13,6 +14,20 @@ export class S3StorageProvider implements StorageProvider {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a character is valid in an HTTP token (RFC 2616)
|
||||
* Tokens can contain: alphanumeric and !#$%&'*+-.^_`|~
|
||||
* Must exclude separators: ()<>@,;:\"/[]?={} and space/tab
|
||||
*/
|
||||
private isTokenChar(char: string): boolean {
|
||||
const code = char.charCodeAt(0);
|
||||
// Basic ASCII range check
|
||||
if (code < 33 || code > 126) return false;
|
||||
// Exclude separator characters per RFC 2616
|
||||
const separators = '()<>@,;:\\"/[]?={} \t';
|
||||
return !separators.includes(char);
|
||||
}
|
||||
|
||||
/**
|
||||
* Safely encode filename for Content-Disposition header
|
||||
*/
|
||||
@@ -40,12 +55,10 @@ export class S3StorageProvider implements StorageProvider {
|
||||
return 'attachment; filename="download"';
|
||||
}
|
||||
|
||||
// Create ASCII-safe version with only valid token characters
|
||||
const asciiSafe = sanitized
|
||||
.split("")
|
||||
.filter((char) => {
|
||||
const code = char.charCodeAt(0);
|
||||
return code >= 32 && code <= 126;
|
||||
})
|
||||
.filter((char) => this.isTokenChar(char))
|
||||
.join("");
|
||||
|
||||
if (asciiSafe && asciiSafe.trim()) {
|
||||
@@ -91,6 +104,7 @@ export class S3StorageProvider implements StorageProvider {
|
||||
Bucket: bucketName,
|
||||
Key: objectName,
|
||||
ResponseContentDisposition: this.encodeFilenameForHeader(rcdFileName),
|
||||
ResponseContentType: getContentType(rcdFileName),
|
||||
});
|
||||
|
||||
return await getSignedUrl(s3Client, command, { expiresIn: expires });
|
||||
@@ -108,4 +122,25 @@ export class S3StorageProvider implements StorageProvider {
|
||||
|
||||
await s3Client.send(command);
|
||||
}
|
||||
|
||||
async fileExists(objectName: string): Promise<boolean> {
|
||||
if (!s3Client) {
|
||||
throw new Error("S3 client is not available");
|
||||
}
|
||||
|
||||
try {
|
||||
const command = new HeadObjectCommand({
|
||||
Bucket: bucketName,
|
||||
Key: objectName,
|
||||
});
|
||||
|
||||
await s3Client.send(command);
|
||||
return true;
|
||||
} catch (error: any) {
|
||||
if (error.name === "NotFound" || error.$metadata?.httpStatusCode === 404) {
|
||||
return false;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
102
apps/server/src/scripts/cleanup-orphan-files.ts
Normal file
102
apps/server/src/scripts/cleanup-orphan-files.ts
Normal file
@@ -0,0 +1,102 @@
|
||||
import { isS3Enabled } from "../config/storage.config";
|
||||
import { FilesystemStorageProvider } from "../providers/filesystem-storage.provider";
|
||||
import { S3StorageProvider } from "../providers/s3-storage.provider";
|
||||
import { prisma } from "../shared/prisma";
|
||||
import { StorageProvider } from "../types/storage";
|
||||
|
||||
/**
|
||||
* Script to clean up orphan file records in the database
|
||||
* (files that are registered in DB but don't exist in storage)
|
||||
*/
|
||||
async function cleanupOrphanFiles() {
|
||||
console.log("Starting orphan file cleanup...");
|
||||
console.log(`Storage mode: ${isS3Enabled ? "S3" : "Filesystem"}`);
|
||||
|
||||
let storageProvider: StorageProvider;
|
||||
if (isS3Enabled) {
|
||||
storageProvider = new S3StorageProvider();
|
||||
} else {
|
||||
storageProvider = FilesystemStorageProvider.getInstance();
|
||||
}
|
||||
|
||||
// Get all files from database
|
||||
const allFiles = await prisma.file.findMany({
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
objectName: true,
|
||||
userId: true,
|
||||
size: true,
|
||||
},
|
||||
});
|
||||
|
||||
console.log(`Found ${allFiles.length} files in database`);
|
||||
|
||||
const orphanFiles: typeof allFiles = [];
|
||||
const existingFiles: typeof allFiles = [];
|
||||
|
||||
// Check each file
|
||||
for (const file of allFiles) {
|
||||
const exists = await storageProvider.fileExists(file.objectName);
|
||||
if (!exists) {
|
||||
orphanFiles.push(file);
|
||||
console.log(`❌ Orphan: ${file.name} (${file.objectName})`);
|
||||
} else {
|
||||
existingFiles.push(file);
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`\n📊 Summary:`);
|
||||
console.log(` Total files in DB: ${allFiles.length}`);
|
||||
console.log(` ✅ Files with storage: ${existingFiles.length}`);
|
||||
console.log(` ❌ Orphan files: ${orphanFiles.length}`);
|
||||
|
||||
if (orphanFiles.length === 0) {
|
||||
console.log("\n✨ No orphan files found!");
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`\n🗑️ Orphan files to be deleted:`);
|
||||
orphanFiles.forEach((file) => {
|
||||
const sizeMB = Number(file.size) / (1024 * 1024);
|
||||
console.log(` - ${file.name} (${sizeMB.toFixed(2)} MB) - ${file.objectName}`);
|
||||
});
|
||||
|
||||
// Ask for confirmation (if running interactively)
|
||||
const shouldDelete = process.argv.includes("--confirm");
|
||||
|
||||
if (!shouldDelete) {
|
||||
console.log(`\n⚠️ Dry run mode. To actually delete orphan records, run with --confirm flag:`);
|
||||
console.log(` node dist/scripts/cleanup-orphan-files.js --confirm`);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`\n🗑️ Deleting orphan file records...`);
|
||||
|
||||
let deletedCount = 0;
|
||||
for (const file of orphanFiles) {
|
||||
try {
|
||||
await prisma.file.delete({
|
||||
where: { id: file.id },
|
||||
});
|
||||
deletedCount++;
|
||||
console.log(` ✓ Deleted: ${file.name}`);
|
||||
} catch (error) {
|
||||
console.error(` ✗ Failed to delete ${file.name}:`, error);
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`\n✅ Cleanup complete!`);
|
||||
console.log(` Deleted ${deletedCount} orphan file records`);
|
||||
}
|
||||
|
||||
// Run the cleanup
|
||||
cleanupOrphanFiles()
|
||||
.then(() => {
|
||||
console.log("\nScript completed successfully");
|
||||
process.exit(0);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("\n❌ Script failed:", error);
|
||||
process.exit(1);
|
||||
});
|
@@ -12,7 +12,9 @@ import { authProvidersRoutes } from "./modules/auth-providers/routes";
|
||||
import { authRoutes } from "./modules/auth/routes";
|
||||
import { fileRoutes } from "./modules/file/routes";
|
||||
import { ChunkManager } from "./modules/filesystem/chunk-manager";
|
||||
import { downloadQueueRoutes } from "./modules/filesystem/download-queue-routes";
|
||||
import { filesystemRoutes } from "./modules/filesystem/routes";
|
||||
import { folderRoutes } from "./modules/folder/routes";
|
||||
import { healthRoutes } from "./modules/health/routes";
|
||||
import { reverseShareRoutes } from "./modules/reverse-share/routes";
|
||||
import { shareRoutes } from "./modules/share/routes";
|
||||
@@ -74,17 +76,18 @@ async function startServer() {
|
||||
app.register(twoFactorRoutes, { prefix: "/auth" });
|
||||
app.register(userRoutes);
|
||||
app.register(fileRoutes);
|
||||
|
||||
if (env.ENABLE_S3 !== "true") {
|
||||
app.register(filesystemRoutes);
|
||||
}
|
||||
|
||||
app.register(folderRoutes);
|
||||
app.register(downloadQueueRoutes);
|
||||
app.register(shareRoutes);
|
||||
app.register(reverseShareRoutes);
|
||||
app.register(storageRoutes);
|
||||
app.register(appRoutes);
|
||||
app.register(healthRoutes);
|
||||
|
||||
if (env.ENABLE_S3 !== "true") {
|
||||
app.register(filesystemRoutes);
|
||||
}
|
||||
|
||||
await app.listen({
|
||||
port: 3333,
|
||||
host: "0.0.0.0",
|
||||
|
52
apps/server/src/types/download-queue.ts
Normal file
52
apps/server/src/types/download-queue.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* TypeScript interfaces for download queue management
|
||||
*/
|
||||
|
||||
export interface QueuedDownloadInfo {
|
||||
downloadId: string;
|
||||
position: number;
|
||||
waitTime: number;
|
||||
fileName?: string;
|
||||
fileSize?: number;
|
||||
}
|
||||
|
||||
export interface QueueStatus {
|
||||
queueLength: number;
|
||||
maxQueueSize: number;
|
||||
activeDownloads: number;
|
||||
maxConcurrent: number;
|
||||
queuedDownloads: QueuedDownloadInfo[];
|
||||
}
|
||||
|
||||
export interface DownloadCancelResponse {
|
||||
message: string;
|
||||
downloadId: string;
|
||||
}
|
||||
|
||||
export interface QueueClearResponse {
|
||||
message: string;
|
||||
clearedCount: number;
|
||||
}
|
||||
|
||||
export interface ApiResponse<T = any> {
|
||||
status: "success" | "error";
|
||||
data?: T;
|
||||
error?: string;
|
||||
message?: string;
|
||||
}
|
||||
|
||||
export interface QueueStatusResponse extends ApiResponse<QueueStatus> {
|
||||
status: "success";
|
||||
data: QueueStatus;
|
||||
}
|
||||
|
||||
export interface DownloadSlotRequest {
|
||||
fileName?: string;
|
||||
fileSize?: number;
|
||||
objectName: string;
|
||||
}
|
||||
|
||||
export interface ActiveDownloadInfo {
|
||||
startTime: number;
|
||||
memoryAtStart: number;
|
||||
}
|
@@ -2,6 +2,7 @@ export interface StorageProvider {
|
||||
getPresignedPutUrl(objectName: string, expires: number): Promise<string>;
|
||||
getPresignedGetUrl(objectName: string, expires: number, fileName?: string): Promise<string>;
|
||||
deleteObject(objectName: string): Promise<void>;
|
||||
fileExists(objectName: string): Promise<boolean>;
|
||||
}
|
||||
|
||||
export interface StorageConfig {
|
||||
|
423
apps/server/src/utils/download-memory-manager.ts
Normal file
423
apps/server/src/utils/download-memory-manager.ts
Normal file
@@ -0,0 +1,423 @@
|
||||
import { ActiveDownloadInfo, DownloadSlotRequest, QueuedDownloadInfo, QueueStatus } from "../types/download-queue";
|
||||
|
||||
interface QueuedDownload {
|
||||
downloadId: string;
|
||||
queuedAt: number;
|
||||
resolve: () => void;
|
||||
reject: (error: Error) => void;
|
||||
metadata?: DownloadSlotRequest;
|
||||
}
|
||||
|
||||
export class DownloadMemoryManager {
|
||||
private static instance: DownloadMemoryManager;
|
||||
private activeDownloads = new Map<string, ActiveDownloadInfo>();
|
||||
private downloadQueue: QueuedDownload[] = [];
|
||||
private maxConcurrentDownloads: number;
|
||||
private memoryThresholdMB: number;
|
||||
private maxQueueSize: number;
|
||||
private cleanupInterval: NodeJS.Timeout;
|
||||
private isAutoScalingEnabled: boolean;
|
||||
private minFileSizeGB: number;
|
||||
|
||||
private constructor() {
|
||||
const { env } = require("../env");
|
||||
|
||||
const totalMemoryGB = require("os").totalmem() / 1024 ** 3;
|
||||
this.isAutoScalingEnabled = env.DOWNLOAD_AUTO_SCALE === "true";
|
||||
|
||||
if (env.DOWNLOAD_MAX_CONCURRENT !== undefined) {
|
||||
this.maxConcurrentDownloads = env.DOWNLOAD_MAX_CONCURRENT;
|
||||
} else if (this.isAutoScalingEnabled) {
|
||||
this.maxConcurrentDownloads = this.calculateDefaultConcurrentDownloads(totalMemoryGB);
|
||||
} else {
|
||||
this.maxConcurrentDownloads = 3;
|
||||
}
|
||||
|
||||
if (env.DOWNLOAD_MEMORY_THRESHOLD_MB !== undefined) {
|
||||
this.memoryThresholdMB = env.DOWNLOAD_MEMORY_THRESHOLD_MB;
|
||||
} else if (this.isAutoScalingEnabled) {
|
||||
this.memoryThresholdMB = this.calculateDefaultMemoryThreshold(totalMemoryGB);
|
||||
} else {
|
||||
this.memoryThresholdMB = 1024;
|
||||
}
|
||||
|
||||
if (env.DOWNLOAD_QUEUE_SIZE !== undefined) {
|
||||
this.maxQueueSize = env.DOWNLOAD_QUEUE_SIZE;
|
||||
} else if (this.isAutoScalingEnabled) {
|
||||
this.maxQueueSize = this.calculateDefaultQueueSize(totalMemoryGB);
|
||||
} else {
|
||||
this.maxQueueSize = 15;
|
||||
}
|
||||
|
||||
if (env.DOWNLOAD_MIN_FILE_SIZE_GB !== undefined) {
|
||||
this.minFileSizeGB = env.DOWNLOAD_MIN_FILE_SIZE_GB;
|
||||
} else {
|
||||
this.minFileSizeGB = 3.0;
|
||||
}
|
||||
|
||||
this.validateConfiguration();
|
||||
|
||||
console.log(`[DOWNLOAD MANAGER] Configuration loaded:`);
|
||||
console.log(` System Memory: ${totalMemoryGB.toFixed(1)}GB`);
|
||||
console.log(
|
||||
` Max Concurrent: ${this.maxConcurrentDownloads} ${env.DOWNLOAD_MAX_CONCURRENT !== undefined ? "(ENV)" : "(AUTO)"}`
|
||||
);
|
||||
console.log(
|
||||
` Memory Threshold: ${this.memoryThresholdMB}MB ${env.DOWNLOAD_MEMORY_THRESHOLD_MB !== undefined ? "(ENV)" : "(AUTO)"}`
|
||||
);
|
||||
console.log(` Queue Size: ${this.maxQueueSize} ${env.DOWNLOAD_QUEUE_SIZE !== undefined ? "(ENV)" : "(AUTO)"}`);
|
||||
console.log(
|
||||
` Min File Size: ${this.minFileSizeGB}GB ${env.DOWNLOAD_MIN_FILE_SIZE_GB !== undefined ? "(ENV)" : "(DEFAULT)"}`
|
||||
);
|
||||
console.log(` Auto-scaling: ${this.isAutoScalingEnabled ? "enabled" : "disabled"}`);
|
||||
|
||||
this.cleanupInterval = setInterval(() => {
|
||||
this.cleanupStaleDownloads();
|
||||
}, 30000);
|
||||
}
|
||||
|
||||
public static getInstance(): DownloadMemoryManager {
|
||||
if (!DownloadMemoryManager.instance) {
|
||||
DownloadMemoryManager.instance = new DownloadMemoryManager();
|
||||
}
|
||||
return DownloadMemoryManager.instance;
|
||||
}
|
||||
|
||||
private calculateDefaultConcurrentDownloads(totalMemoryGB: number): number {
|
||||
if (totalMemoryGB > 16) return 10;
|
||||
if (totalMemoryGB > 8) return 5;
|
||||
if (totalMemoryGB > 4) return 3;
|
||||
if (totalMemoryGB > 2) return 2;
|
||||
return 1;
|
||||
}
|
||||
|
||||
private calculateDefaultMemoryThreshold(totalMemoryGB: number): number {
|
||||
if (totalMemoryGB > 16) return 4096; // 4GB
|
||||
if (totalMemoryGB > 8) return 2048; // 2GB
|
||||
if (totalMemoryGB > 4) return 1024; // 1GB
|
||||
if (totalMemoryGB > 2) return 512; // 512MB
|
||||
return 256; // 256MB
|
||||
}
|
||||
|
||||
private calculateDefaultQueueSize(totalMemoryGB: number): number {
|
||||
if (totalMemoryGB > 16) return 50; // Large queue for powerful servers
|
||||
if (totalMemoryGB > 8) return 25; // Medium queue
|
||||
if (totalMemoryGB > 4) return 15; // Small queue
|
||||
if (totalMemoryGB > 2) return 10; // Very small queue
|
||||
return 5; // Minimal queue
|
||||
}
|
||||
|
||||
private validateConfiguration(): void {
|
||||
const warnings: string[] = [];
|
||||
const errors: string[] = [];
|
||||
|
||||
if (this.maxConcurrentDownloads < 1) {
|
||||
errors.push(`DOWNLOAD_MAX_CONCURRENT must be >= 1, got: ${this.maxConcurrentDownloads}`);
|
||||
}
|
||||
if (this.maxConcurrentDownloads > 50) {
|
||||
warnings.push(
|
||||
`DOWNLOAD_MAX_CONCURRENT is very high (${this.maxConcurrentDownloads}), this may cause performance issues`
|
||||
);
|
||||
}
|
||||
|
||||
if (this.memoryThresholdMB < 128) {
|
||||
warnings.push(
|
||||
`DOWNLOAD_MEMORY_THRESHOLD_MB is very low (${this.memoryThresholdMB}MB), downloads may be throttled frequently`
|
||||
);
|
||||
}
|
||||
if (this.memoryThresholdMB > 16384) {
|
||||
warnings.push(
|
||||
`DOWNLOAD_MEMORY_THRESHOLD_MB is very high (${this.memoryThresholdMB}MB), system may run out of memory`
|
||||
);
|
||||
}
|
||||
|
||||
if (this.maxQueueSize < 1) {
|
||||
errors.push(`DOWNLOAD_QUEUE_SIZE must be >= 1, got: ${this.maxQueueSize}`);
|
||||
}
|
||||
if (this.maxQueueSize > 1000) {
|
||||
warnings.push(`DOWNLOAD_QUEUE_SIZE is very high (${this.maxQueueSize}), this may consume significant memory`);
|
||||
}
|
||||
|
||||
if (this.minFileSizeGB < 0.1) {
|
||||
warnings.push(
|
||||
`DOWNLOAD_MIN_FILE_SIZE_GB is very low (${this.minFileSizeGB}GB), most downloads will use memory management`
|
||||
);
|
||||
}
|
||||
if (this.minFileSizeGB > 50) {
|
||||
warnings.push(
|
||||
`DOWNLOAD_MIN_FILE_SIZE_GB is very high (${this.minFileSizeGB}GB), memory management may rarely activate`
|
||||
);
|
||||
}
|
||||
|
||||
const recommendedQueueSize = this.maxConcurrentDownloads * 5;
|
||||
if (this.maxQueueSize < this.maxConcurrentDownloads) {
|
||||
warnings.push(
|
||||
`DOWNLOAD_QUEUE_SIZE (${this.maxQueueSize}) is smaller than DOWNLOAD_MAX_CONCURRENT (${this.maxConcurrentDownloads})`
|
||||
);
|
||||
} else if (this.maxQueueSize < recommendedQueueSize) {
|
||||
warnings.push(
|
||||
`DOWNLOAD_QUEUE_SIZE (${this.maxQueueSize}) might be too small. Recommended: ${recommendedQueueSize} (5x concurrent downloads)`
|
||||
);
|
||||
}
|
||||
|
||||
if (warnings.length > 0) {
|
||||
console.warn(`[DOWNLOAD MANAGER] Configuration warnings:`);
|
||||
warnings.forEach((warning) => console.warn(` - ${warning}`));
|
||||
}
|
||||
|
||||
if (errors.length > 0) {
|
||||
console.error(`[DOWNLOAD MANAGER] Configuration errors:`);
|
||||
errors.forEach((error) => console.error(` - ${error}`));
|
||||
throw new Error(`Invalid download manager configuration: ${errors.join(", ")}`);
|
||||
}
|
||||
}
|
||||
|
||||
public async requestDownloadSlot(downloadId: string, metadata?: DownloadSlotRequest): Promise<void> {
|
||||
if (metadata?.fileSize) {
|
||||
const fileSizeGB = metadata.fileSize / 1024 ** 3;
|
||||
if (fileSizeGB < this.minFileSizeGB) {
|
||||
console.log(
|
||||
`[DOWNLOAD MANAGER] File ${metadata.fileName || "unknown"} (${fileSizeGB.toFixed(2)}GB) below threshold (${this.minFileSizeGB}GB), bypassing queue`
|
||||
);
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
|
||||
if (this.canStartImmediately()) {
|
||||
console.log(`[DOWNLOAD MANAGER] Immediate start: ${downloadId}`);
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
if (this.downloadQueue.length >= this.maxQueueSize) {
|
||||
const error = new Error(`Download queue is full: ${this.downloadQueue.length}/${this.maxQueueSize}`);
|
||||
throw error;
|
||||
}
|
||||
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
const queuedDownload: QueuedDownload = {
|
||||
downloadId,
|
||||
queuedAt: Date.now(),
|
||||
resolve,
|
||||
reject,
|
||||
metadata,
|
||||
};
|
||||
|
||||
this.downloadQueue.push(queuedDownload);
|
||||
|
||||
const position = this.downloadQueue.length;
|
||||
console.log(`[DOWNLOAD MANAGER] Queued: ${downloadId} (Position: ${position}/${this.maxQueueSize})`);
|
||||
|
||||
if (metadata?.fileName && metadata?.fileSize) {
|
||||
const sizeMB = (metadata.fileSize / (1024 * 1024)).toFixed(1);
|
||||
console.log(`[DOWNLOAD MANAGER] Queued file: ${metadata.fileName} (${sizeMB}MB)`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private canStartImmediately(): boolean {
|
||||
const currentMemoryMB = this.getCurrentMemoryUsage();
|
||||
|
||||
if (currentMemoryMB > this.memoryThresholdMB) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.activeDownloads.size >= this.maxConcurrentDownloads) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public canStartDownload(): { allowed: boolean; reason?: string } {
|
||||
if (this.canStartImmediately()) {
|
||||
return { allowed: true };
|
||||
}
|
||||
|
||||
const currentMemoryMB = this.getCurrentMemoryUsage();
|
||||
|
||||
if (currentMemoryMB > this.memoryThresholdMB) {
|
||||
return {
|
||||
allowed: false,
|
||||
reason: `Memory usage too high: ${currentMemoryMB.toFixed(0)}MB > ${this.memoryThresholdMB}MB`,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
allowed: false,
|
||||
reason: `Too many concurrent downloads: ${this.activeDownloads.size}/${this.maxConcurrentDownloads}`,
|
||||
};
|
||||
}
|
||||
|
||||
public startDownload(downloadId: string): void {
|
||||
const memUsage = process.memoryUsage();
|
||||
this.activeDownloads.set(downloadId, {
|
||||
startTime: Date.now(),
|
||||
memoryAtStart: memUsage.rss + memUsage.external,
|
||||
});
|
||||
|
||||
console.log(
|
||||
`[DOWNLOAD MANAGER] Started: ${downloadId} (${this.activeDownloads.size}/${this.maxConcurrentDownloads} active)`
|
||||
);
|
||||
}
|
||||
|
||||
public endDownload(downloadId: string): void {
|
||||
const downloadInfo = this.activeDownloads.get(downloadId);
|
||||
this.activeDownloads.delete(downloadId);
|
||||
|
||||
if (downloadInfo) {
|
||||
const duration = Date.now() - downloadInfo.startTime;
|
||||
const memUsage = process.memoryUsage();
|
||||
const currentMemory = memUsage.rss + memUsage.external;
|
||||
const memoryDiff = currentMemory - downloadInfo.memoryAtStart;
|
||||
|
||||
console.log(
|
||||
`[DOWNLOAD MANAGER] Ended: ${downloadId} (Duration: ${(duration / 1000).toFixed(1)}s, Memory delta: ${(memoryDiff / 1024 / 1024).toFixed(1)}MB)`
|
||||
);
|
||||
|
||||
if (memoryDiff > 100 * 1024 * 1024 && global.gc) {
|
||||
setImmediate(() => {
|
||||
global.gc!();
|
||||
console.log(`[DOWNLOAD MANAGER] Forced GC after download ${downloadId}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
this.processQueue();
|
||||
}
|
||||
|
||||
private processQueue(): void {
|
||||
if (this.downloadQueue.length === 0 || !this.canStartImmediately()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const nextDownload = this.downloadQueue.shift();
|
||||
if (!nextDownload) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(
|
||||
`[DOWNLOAD MANAGER] Processing queue: ${nextDownload.downloadId} (${this.downloadQueue.length} remaining)`
|
||||
);
|
||||
|
||||
if (nextDownload.metadata?.fileName && nextDownload.metadata?.fileSize) {
|
||||
const sizeMB = (nextDownload.metadata.fileSize / (1024 * 1024)).toFixed(1);
|
||||
console.log(`[DOWNLOAD MANAGER] Starting queued file: ${nextDownload.metadata.fileName} (${sizeMB}MB)`);
|
||||
}
|
||||
|
||||
nextDownload.resolve();
|
||||
}
|
||||
|
||||
public getActiveDownloadsCount(): number {
|
||||
return this.activeDownloads.size;
|
||||
}
|
||||
|
||||
private getCurrentMemoryUsage(): number {
|
||||
const usage = process.memoryUsage();
|
||||
return (usage.rss + usage.external) / (1024 * 1024);
|
||||
}
|
||||
|
||||
public getCurrentMemoryUsageMB(): number {
|
||||
return this.getCurrentMemoryUsage();
|
||||
}
|
||||
|
||||
public getQueueStatus(): QueueStatus {
|
||||
return {
|
||||
queueLength: this.downloadQueue.length,
|
||||
maxQueueSize: this.maxQueueSize,
|
||||
activeDownloads: this.activeDownloads.size,
|
||||
maxConcurrent: this.maxConcurrentDownloads,
|
||||
queuedDownloads: this.downloadQueue.map((download, index) => ({
|
||||
downloadId: download.downloadId,
|
||||
position: index + 1,
|
||||
waitTime: Date.now() - download.queuedAt,
|
||||
fileName: download.metadata?.fileName,
|
||||
fileSize: download.metadata?.fileSize,
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
public cancelQueuedDownload(downloadId: string): boolean {
|
||||
const index = this.downloadQueue.findIndex((item) => item.downloadId === downloadId);
|
||||
|
||||
if (index === -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const canceledDownload = this.downloadQueue.splice(index, 1)[0];
|
||||
canceledDownload.reject(new Error(`Download ${downloadId} was cancelled`));
|
||||
|
||||
console.log(`[DOWNLOAD MANAGER] Cancelled queued download: ${downloadId} (was at position ${index + 1})`);
|
||||
return true;
|
||||
}
|
||||
|
||||
private cleanupStaleDownloads(): void {
|
||||
const now = Date.now();
|
||||
const staleThreshold = 10 * 60 * 1000; // 10 minutes
|
||||
const queueStaleThreshold = 30 * 60 * 1000;
|
||||
|
||||
for (const [downloadId, info] of this.activeDownloads.entries()) {
|
||||
if (now - info.startTime > staleThreshold) {
|
||||
console.warn(`[DOWNLOAD MANAGER] Cleaning up stale active download: ${downloadId}`);
|
||||
this.activeDownloads.delete(downloadId);
|
||||
}
|
||||
}
|
||||
|
||||
const initialQueueLength = this.downloadQueue.length;
|
||||
this.downloadQueue = this.downloadQueue.filter((download) => {
|
||||
if (now - download.queuedAt > queueStaleThreshold) {
|
||||
console.warn(`[DOWNLOAD MANAGER] Cleaning up stale queued download: ${download.downloadId}`);
|
||||
download.reject(new Error(`Download ${download.downloadId} timed out in queue`));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
if (this.downloadQueue.length < initialQueueLength) {
|
||||
console.log(
|
||||
`[DOWNLOAD MANAGER] Cleaned up ${initialQueueLength - this.downloadQueue.length} stale queued downloads`
|
||||
);
|
||||
}
|
||||
|
||||
this.processQueue();
|
||||
}
|
||||
|
||||
public shouldThrottleStream(): boolean {
|
||||
const currentMemoryMB = this.getCurrentMemoryUsageMB();
|
||||
return currentMemoryMB > this.memoryThresholdMB * 0.8;
|
||||
}
|
||||
|
||||
public getThrottleDelay(): number {
|
||||
const currentMemoryMB = this.getCurrentMemoryUsageMB();
|
||||
const thresholdRatio = currentMemoryMB / this.memoryThresholdMB;
|
||||
|
||||
if (thresholdRatio > 0.9) return 200;
|
||||
if (thresholdRatio > 0.8) return 100;
|
||||
return 50;
|
||||
}
|
||||
|
||||
public destroy(): void {
|
||||
if (this.cleanupInterval) {
|
||||
clearInterval(this.cleanupInterval);
|
||||
}
|
||||
|
||||
this.downloadQueue.forEach((download) => {
|
||||
download.reject(new Error("Download manager is shutting down"));
|
||||
});
|
||||
|
||||
this.activeDownloads.clear();
|
||||
this.downloadQueue = [];
|
||||
console.log("[DOWNLOAD MANAGER] Shutdown completed");
|
||||
}
|
||||
|
||||
public clearQueue(): number {
|
||||
const clearedCount = this.downloadQueue.length;
|
||||
|
||||
this.downloadQueue.forEach((download) => {
|
||||
download.reject(new Error("Queue was cleared by administrator"));
|
||||
});
|
||||
|
||||
this.downloadQueue = [];
|
||||
console.log(`[DOWNLOAD MANAGER] Cleared queue: ${clearedCount} downloads cancelled`);
|
||||
return clearedCount;
|
||||
}
|
||||
}
|
206
apps/server/src/utils/file-name-generator.ts
Normal file
206
apps/server/src/utils/file-name-generator.ts
Normal file
@@ -0,0 +1,206 @@
|
||||
import { prisma } from "../shared/prisma";
|
||||
|
||||
/**
|
||||
* Generates a unique filename by checking for duplicates in the database
|
||||
* and appending a numeric suffix if necessary (e.g., file (1).txt, file (2).txt)
|
||||
*
|
||||
* @param baseName - The original filename without extension
|
||||
* @param extension - The file extension
|
||||
* @param userId - The user ID who owns the file
|
||||
* @param folderId - The folder ID where the file will be stored (null for root)
|
||||
* @returns A unique filename with extension
|
||||
*/
|
||||
export async function generateUniqueFileName(
|
||||
baseName: string,
|
||||
extension: string,
|
||||
userId: string,
|
||||
folderId: string | null | undefined
|
||||
): Promise<string> {
|
||||
const fullName = `${baseName}.${extension}`;
|
||||
const targetFolderId = folderId || null;
|
||||
|
||||
// Check if the original filename exists in the target folder
|
||||
const existingFile = await prisma.file.findFirst({
|
||||
where: {
|
||||
name: fullName,
|
||||
userId,
|
||||
folderId: targetFolderId,
|
||||
},
|
||||
});
|
||||
|
||||
// If no duplicate, return the original name
|
||||
if (!existingFile) {
|
||||
return fullName;
|
||||
}
|
||||
|
||||
// Find the next available suffix number
|
||||
let suffix = 1;
|
||||
let uniqueName = `${baseName} (${suffix}).${extension}`;
|
||||
|
||||
while (true) {
|
||||
const duplicateFile = await prisma.file.findFirst({
|
||||
where: {
|
||||
name: uniqueName,
|
||||
userId,
|
||||
folderId: targetFolderId,
|
||||
},
|
||||
});
|
||||
|
||||
if (!duplicateFile) {
|
||||
return uniqueName;
|
||||
}
|
||||
|
||||
suffix++;
|
||||
uniqueName = `${baseName} (${suffix}).${extension}`;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a unique filename for rename operations by checking for duplicates
|
||||
* and appending a numeric suffix if necessary (e.g., file (1).txt, file (2).txt)
|
||||
*
|
||||
* @param baseName - The original filename without extension
|
||||
* @param extension - The file extension
|
||||
* @param userId - The user ID who owns the file
|
||||
* @param folderId - The folder ID where the file will be stored (null for root)
|
||||
* @param excludeFileId - The ID of the file being renamed (to exclude from duplicate check)
|
||||
* @returns A unique filename with extension
|
||||
*/
|
||||
export async function generateUniqueFileNameForRename(
|
||||
baseName: string,
|
||||
extension: string,
|
||||
userId: string,
|
||||
folderId: string | null | undefined,
|
||||
excludeFileId: string
|
||||
): Promise<string> {
|
||||
const fullName = `${baseName}.${extension}`;
|
||||
const targetFolderId = folderId || null;
|
||||
|
||||
// Check if the original filename exists in the target folder (excluding current file)
|
||||
const existingFile = await prisma.file.findFirst({
|
||||
where: {
|
||||
name: fullName,
|
||||
userId,
|
||||
folderId: targetFolderId,
|
||||
id: { not: excludeFileId },
|
||||
},
|
||||
});
|
||||
|
||||
// If no duplicate, return the original name
|
||||
if (!existingFile) {
|
||||
return fullName;
|
||||
}
|
||||
|
||||
// Find the next available suffix number
|
||||
let suffix = 1;
|
||||
let uniqueName = `${baseName} (${suffix}).${extension}`;
|
||||
|
||||
while (true) {
|
||||
const duplicateFile = await prisma.file.findFirst({
|
||||
where: {
|
||||
name: uniqueName,
|
||||
userId,
|
||||
folderId: targetFolderId,
|
||||
id: { not: excludeFileId },
|
||||
},
|
||||
});
|
||||
|
||||
if (!duplicateFile) {
|
||||
return uniqueName;
|
||||
}
|
||||
|
||||
suffix++;
|
||||
uniqueName = `${baseName} (${suffix}).${extension}`;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a unique folder name by checking for duplicates in the database
|
||||
* and appending a numeric suffix if necessary (e.g., folder (1), folder (2))
|
||||
*
|
||||
* @param name - The original folder name
|
||||
* @param userId - The user ID who owns the folder
|
||||
* @param parentId - The parent folder ID (null for root)
|
||||
* @param excludeFolderId - The ID of the folder being renamed (to exclude from duplicate check)
|
||||
* @returns A unique folder name
|
||||
*/
|
||||
export async function generateUniqueFolderName(
|
||||
name: string,
|
||||
userId: string,
|
||||
parentId: string | null | undefined,
|
||||
excludeFolderId?: string
|
||||
): Promise<string> {
|
||||
const targetParentId = parentId || null;
|
||||
|
||||
// Build the where clause
|
||||
const whereClause: any = {
|
||||
name,
|
||||
userId,
|
||||
parentId: targetParentId,
|
||||
};
|
||||
|
||||
// Exclude the current folder if this is a rename operation
|
||||
if (excludeFolderId) {
|
||||
whereClause.id = { not: excludeFolderId };
|
||||
}
|
||||
|
||||
// Check if the original folder name exists in the target location
|
||||
const existingFolder = await prisma.folder.findFirst({
|
||||
where: whereClause,
|
||||
});
|
||||
|
||||
// If no duplicate, return the original name
|
||||
if (!existingFolder) {
|
||||
return name;
|
||||
}
|
||||
|
||||
// Find the next available suffix number
|
||||
let suffix = 1;
|
||||
let uniqueName = `${name} (${suffix})`;
|
||||
|
||||
while (true) {
|
||||
const whereClauseForSuffix: any = {
|
||||
name: uniqueName,
|
||||
userId,
|
||||
parentId: targetParentId,
|
||||
};
|
||||
|
||||
if (excludeFolderId) {
|
||||
whereClauseForSuffix.id = { not: excludeFolderId };
|
||||
}
|
||||
|
||||
const duplicateFolder = await prisma.folder.findFirst({
|
||||
where: whereClauseForSuffix,
|
||||
});
|
||||
|
||||
if (!duplicateFolder) {
|
||||
return uniqueName;
|
||||
}
|
||||
|
||||
suffix++;
|
||||
uniqueName = `${name} (${suffix})`;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a filename into base name and extension
|
||||
*
|
||||
* @param filename - The full filename with extension
|
||||
* @returns Object with baseName and extension
|
||||
*/
|
||||
export function parseFileName(filename: string): { baseName: string; extension: string } {
|
||||
const lastDotIndex = filename.lastIndexOf(".");
|
||||
|
||||
if (lastDotIndex === -1 || lastDotIndex === 0) {
|
||||
// No extension or hidden file with no name before dot
|
||||
return {
|
||||
baseName: filename,
|
||||
extension: "",
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
baseName: filename.substring(0, lastDotIndex),
|
||||
extension: filename.substring(lastDotIndex + 1),
|
||||
};
|
||||
}
|
378
apps/server/src/utils/mime-types.ts
Normal file
378
apps/server/src/utils/mime-types.ts
Normal file
@@ -0,0 +1,378 @@
|
||||
/**
|
||||
* Utility for detecting MIME types based on file extensions
|
||||
* Fallback to application/octet-stream if extension is unknown
|
||||
*/
|
||||
|
||||
const mimeTypeMap: Record<string, string> = {
|
||||
// Images
|
||||
".jpg": "image/jpeg",
|
||||
".jpeg": "image/jpeg",
|
||||
".png": "image/png",
|
||||
".gif": "image/gif",
|
||||
".bmp": "image/bmp",
|
||||
".webp": "image/webp",
|
||||
".svg": "image/svg+xml",
|
||||
".ico": "image/x-icon",
|
||||
".tiff": "image/tiff",
|
||||
".tif": "image/tiff",
|
||||
".avif": "image/avif",
|
||||
".heic": "image/heic",
|
||||
".heif": "image/heif",
|
||||
".jxl": "image/jxl",
|
||||
".psd": "image/vnd.adobe.photoshop",
|
||||
".raw": "image/x-canon-cr2",
|
||||
".cr2": "image/x-canon-cr2",
|
||||
".nef": "image/x-nikon-nef",
|
||||
".arw": "image/x-sony-arw",
|
||||
".dng": "image/x-adobe-dng",
|
||||
".xcf": "image/x-xcf",
|
||||
".pbm": "image/x-portable-bitmap",
|
||||
".pgm": "image/x-portable-graymap",
|
||||
".ppm": "image/x-portable-pixmap",
|
||||
".pnm": "image/x-portable-anymap",
|
||||
|
||||
// Documents
|
||||
".pdf": "application/pdf",
|
||||
".doc": "application/msword",
|
||||
".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||
".docm": "application/vnd.ms-word.document.macroEnabled.12",
|
||||
".dotx": "application/vnd.openxmlformats-officedocument.wordprocessingml.template",
|
||||
".dotm": "application/vnd.ms-word.template.macroEnabled.12",
|
||||
".xls": "application/vnd.ms-excel",
|
||||
".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
".xlsm": "application/vnd.ms-excel.sheet.macroEnabled.12",
|
||||
".xltx": "application/vnd.openxmlformats-officedocument.spreadsheetml.template",
|
||||
".xltm": "application/vnd.ms-excel.template.macroEnabled.12",
|
||||
".xlsb": "application/vnd.ms-excel.sheet.binary.macroEnabled.12",
|
||||
".ppt": "application/vnd.ms-powerpoint",
|
||||
".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
||||
".pptm": "application/vnd.ms-powerpoint.presentation.macroEnabled.12",
|
||||
".potx": "application/vnd.openxmlformats-officedocument.presentationml.template",
|
||||
".potm": "application/vnd.ms-powerpoint.template.macroEnabled.12",
|
||||
".ppsx": "application/vnd.openxmlformats-officedocument.presentationml.slideshow",
|
||||
".ppsm": "application/vnd.ms-powerpoint.slideshow.macroEnabled.12",
|
||||
".odt": "application/vnd.oasis.opendocument.text",
|
||||
".ods": "application/vnd.oasis.opendocument.spreadsheet",
|
||||
".odp": "application/vnd.oasis.opendocument.presentation",
|
||||
".odg": "application/vnd.oasis.opendocument.graphics",
|
||||
".odf": "application/vnd.oasis.opendocument.formula",
|
||||
".odb": "application/vnd.oasis.opendocument.database",
|
||||
".odc": "application/vnd.oasis.opendocument.chart",
|
||||
".odi": "application/vnd.oasis.opendocument.image",
|
||||
|
||||
// Text and Code
|
||||
".txt": "text/plain",
|
||||
".html": "text/html",
|
||||
".htm": "text/html",
|
||||
".css": "text/css",
|
||||
".js": "application/javascript",
|
||||
".mjs": "application/javascript",
|
||||
".ts": "text/typescript",
|
||||
".tsx": "text/tsx",
|
||||
".jsx": "text/jsx",
|
||||
".json": "application/json",
|
||||
".xml": "application/xml",
|
||||
".csv": "text/csv",
|
||||
".yaml": "text/yaml",
|
||||
".yml": "text/yaml",
|
||||
".toml": "text/plain",
|
||||
".ini": "text/plain",
|
||||
".cfg": "text/plain",
|
||||
".conf": "text/plain",
|
||||
".log": "text/plain",
|
||||
".md": "text/markdown",
|
||||
".markdown": "text/markdown",
|
||||
".rst": "text/x-rst",
|
||||
".tex": "text/x-tex",
|
||||
".latex": "text/x-latex",
|
||||
".rtf": "application/rtf",
|
||||
".ps": "application/postscript",
|
||||
".eps": "application/postscript",
|
||||
|
||||
// Programming Languages
|
||||
".c": "text/x-c",
|
||||
".cc": "text/x-c",
|
||||
".cpp": "text/x-c",
|
||||
".cxx": "text/x-c",
|
||||
".h": "text/x-c",
|
||||
".hpp": "text/x-c",
|
||||
".hxx": "text/x-c",
|
||||
".java": "text/x-java-source",
|
||||
".class": "application/java-vm",
|
||||
".jar": "application/java-archive",
|
||||
".war": "application/java-archive",
|
||||
".py": "text/x-python",
|
||||
".pyw": "text/x-python",
|
||||
".rb": "text/x-ruby",
|
||||
".php": "text/x-php",
|
||||
".pl": "text/x-perl",
|
||||
".pm": "text/x-perl",
|
||||
".sh": "text/x-shellscript",
|
||||
".bash": "text/x-shellscript",
|
||||
".zsh": "text/x-shellscript",
|
||||
".fish": "text/x-shellscript",
|
||||
".bat": "text/x-msdos-batch",
|
||||
".cmd": "text/x-msdos-batch",
|
||||
".ps1": "text/plain",
|
||||
".psm1": "text/plain",
|
||||
".go": "text/x-go",
|
||||
".rs": "text/x-rust",
|
||||
".swift": "text/x-swift",
|
||||
".kt": "text/x-kotlin",
|
||||
".scala": "text/x-scala",
|
||||
".clj": "text/x-clojure",
|
||||
".hs": "text/x-haskell",
|
||||
".elm": "text/x-elm",
|
||||
".dart": "text/x-dart",
|
||||
".r": "text/x-r",
|
||||
".R": "text/x-r",
|
||||
".sql": "text/x-sql",
|
||||
".vb": "text/x-vb",
|
||||
".cs": "text/x-csharp",
|
||||
".fs": "text/x-fsharp",
|
||||
".lua": "text/x-lua",
|
||||
".m": "text/x-objc",
|
||||
".mm": "text/x-objc",
|
||||
|
||||
// Audio
|
||||
".mp3": "audio/mpeg",
|
||||
".mp2": "audio/mpeg",
|
||||
".m4a": "audio/mp4",
|
||||
".m4b": "audio/mp4",
|
||||
".m4p": "audio/mp4",
|
||||
".wav": "audio/wav",
|
||||
".wave": "audio/wav",
|
||||
".aiff": "audio/aiff",
|
||||
".aif": "audio/aiff",
|
||||
".aifc": "audio/aiff",
|
||||
".flac": "audio/flac",
|
||||
".ogg": "audio/ogg",
|
||||
".oga": "audio/ogg",
|
||||
".opus": "audio/opus",
|
||||
".aac": "audio/aac",
|
||||
".wma": "audio/x-ms-wma",
|
||||
".ac3": "audio/ac3",
|
||||
".amr": "audio/amr",
|
||||
".au": "audio/basic",
|
||||
".snd": "audio/basic",
|
||||
".mid": "audio/midi",
|
||||
".midi": "audio/midi",
|
||||
".kar": "audio/midi",
|
||||
".ra": "audio/x-realaudio",
|
||||
".ram": "audio/x-realaudio",
|
||||
".3gp": "audio/3gpp",
|
||||
".3g2": "audio/3gpp2",
|
||||
".spx": "audio/speex",
|
||||
".wv": "audio/x-wavpack",
|
||||
".ape": "audio/x-ape",
|
||||
".mpc": "audio/x-musepack",
|
||||
|
||||
// Video
|
||||
".mp4": "video/mp4",
|
||||
".m4v": "video/mp4",
|
||||
".avi": "video/x-msvideo",
|
||||
".mov": "video/quicktime",
|
||||
".qt": "video/quicktime",
|
||||
".wmv": "video/x-ms-wmv",
|
||||
".asf": "video/x-ms-asf",
|
||||
".flv": "video/x-flv",
|
||||
".f4v": "video/x-f4v",
|
||||
".webm": "video/webm",
|
||||
".mkv": "video/x-matroska",
|
||||
".mka": "audio/x-matroska",
|
||||
".mks": "video/x-matroska",
|
||||
".ogv": "video/ogg",
|
||||
".ogm": "video/ogg",
|
||||
".mxf": "application/mxf",
|
||||
".m2ts": "video/mp2t",
|
||||
".mts": "video/mp2t",
|
||||
".vob": "video/dvd",
|
||||
".mpg": "video/mpeg",
|
||||
".mpeg": "video/mpeg",
|
||||
".m1v": "video/mpeg",
|
||||
".m2v": "video/mpeg",
|
||||
".rm": "application/vnd.rn-realmedia",
|
||||
".rmvb": "application/vnd.rn-realmedia-vbr",
|
||||
".divx": "video/divx",
|
||||
".xvid": "video/x-xvid",
|
||||
|
||||
// Archives and Compression
|
||||
".zip": "application/zip",
|
||||
".rar": "application/vnd.rar",
|
||||
".7z": "application/x-7z-compressed",
|
||||
".tar": "application/x-tar",
|
||||
".tar.gz": "application/gzip",
|
||||
".tgz": "application/gzip",
|
||||
".tar.bz2": "application/x-bzip2",
|
||||
".tbz2": "application/x-bzip2",
|
||||
".tar.xz": "application/x-xz",
|
||||
".txz": "application/x-xz",
|
||||
".tar.lz": "application/x-lzip",
|
||||
".tar.Z": "application/x-compress",
|
||||
".Z": "application/x-compress",
|
||||
".gz": "application/gzip",
|
||||
".bz2": "application/x-bzip2",
|
||||
".xz": "application/x-xz",
|
||||
".lz": "application/x-lzip",
|
||||
".lzma": "application/x-lzma",
|
||||
".lzo": "application/x-lzop",
|
||||
".arj": "application/x-arj",
|
||||
".ace": "application/x-ace-compressed",
|
||||
".cab": "application/vnd.ms-cab-compressed",
|
||||
".iso": "application/x-iso9660-image",
|
||||
".dmg": "application/x-apple-diskimage",
|
||||
".img": "application/x-img",
|
||||
".bin": "application/octet-stream",
|
||||
".cue": "application/x-cue",
|
||||
".nrg": "application/x-nrg",
|
||||
".mdf": "application/x-mdf",
|
||||
".toast": "application/x-toast",
|
||||
|
||||
// Executables and System
|
||||
".exe": "application/vnd.microsoft.portable-executable",
|
||||
".dll": "application/vnd.microsoft.portable-executable",
|
||||
".msi": "application/x-msdownload",
|
||||
".msp": "application/x-msdownload",
|
||||
".deb": "application/vnd.debian.binary-package",
|
||||
".rpm": "application/x-rpm",
|
||||
".pkg": "application/x-newton-compatible-pkg",
|
||||
".apk": "application/vnd.android.package-archive",
|
||||
".ipa": "application/octet-stream",
|
||||
".app": "application/octet-stream",
|
||||
".snap": "application/x-snap",
|
||||
".flatpak": "application/vnd.flatpak",
|
||||
".appimage": "application/x-appimage",
|
||||
|
||||
// Adobe and Design
|
||||
".ai": "application/illustrator",
|
||||
".indd": "application/x-indesign",
|
||||
".idml": "application/vnd.adobe.indesign-idml-package",
|
||||
".sketch": "application/x-sketch",
|
||||
".fig": "application/x-figma",
|
||||
".xd": "application/vnd.adobe.xd",
|
||||
|
||||
// Fonts
|
||||
".ttf": "font/ttf",
|
||||
".otf": "font/otf",
|
||||
".woff": "font/woff",
|
||||
".woff2": "font/woff2",
|
||||
".eot": "application/vnd.ms-fontobject",
|
||||
".fon": "application/x-font-bdf",
|
||||
".bdf": "application/x-font-bdf",
|
||||
".pcf": "application/x-font-pcf",
|
||||
".pfb": "application/x-font-type1",
|
||||
".pfm": "application/x-font-type1",
|
||||
".afm": "application/x-font-afm",
|
||||
|
||||
// E-books
|
||||
".epub": "application/epub+zip",
|
||||
".mobi": "application/x-mobipocket-ebook",
|
||||
".azw": "application/vnd.amazon.ebook",
|
||||
".azw3": "application/vnd.amazon.ebook",
|
||||
".fb2": "application/x-fictionbook+xml",
|
||||
".lit": "application/x-ms-reader",
|
||||
".pdb": "application/vnd.palm",
|
||||
".prc": "application/vnd.palm",
|
||||
".tcr": "application/x-psion3-s",
|
||||
|
||||
// CAD and 3D
|
||||
".dwg": "image/vnd.dwg",
|
||||
".dxf": "image/vnd.dxf",
|
||||
".step": "application/step",
|
||||
".stp": "application/step",
|
||||
".iges": "application/iges",
|
||||
".igs": "application/iges",
|
||||
".stl": "application/sla",
|
||||
".obj": "application/x-tgif",
|
||||
".3ds": "application/x-3ds",
|
||||
".dae": "model/vnd.collada+xml",
|
||||
".ply": "application/ply",
|
||||
".x3d": "model/x3d+xml",
|
||||
|
||||
// Database
|
||||
".db": "application/x-sqlite3",
|
||||
".sqlite": "application/x-sqlite3",
|
||||
".sqlite3": "application/x-sqlite3",
|
||||
".mdb": "application/x-msaccess",
|
||||
".accdb": "application/x-msaccess",
|
||||
|
||||
// Virtual Machine and Disk Images
|
||||
".vmdk": "application/x-vmdk",
|
||||
".vdi": "application/x-virtualbox-vdi",
|
||||
".vhd": "application/x-virtualbox-vhd",
|
||||
".vhdx": "application/x-virtualbox-vhdx",
|
||||
".ova": "application/x-virtualbox-ova",
|
||||
".ovf": "application/x-virtualbox-ovf",
|
||||
".qcow2": "application/x-qemu-disk",
|
||||
|
||||
// Scientific and Math
|
||||
".mat": "application/x-matlab-data",
|
||||
".nc": "application/x-netcdf",
|
||||
".cdf": "application/x-netcdf",
|
||||
".hdf": "application/x-hdf",
|
||||
".h5": "application/x-hdf5",
|
||||
|
||||
// Misc Application Formats
|
||||
".torrent": "application/x-bittorrent",
|
||||
".rss": "application/rss+xml",
|
||||
".atom": "application/atom+xml",
|
||||
".gpx": "application/gpx+xml",
|
||||
".kml": "application/vnd.google-earth.kml+xml",
|
||||
".kmz": "application/vnd.google-earth.kmz",
|
||||
".ics": "text/calendar",
|
||||
".vcs": "text/x-vcalendar",
|
||||
".vcf": "text/x-vcard",
|
||||
".p7s": "application/pkcs7-signature",
|
||||
".p7m": "application/pkcs7-mime",
|
||||
".p12": "application/x-pkcs12",
|
||||
".pfx": "application/x-pkcs12",
|
||||
".cer": "application/x-x509-ca-cert",
|
||||
".crt": "application/x-x509-ca-cert",
|
||||
".pem": "application/x-pem-file",
|
||||
".key": "application/x-pem-file",
|
||||
};
|
||||
|
||||
/**
|
||||
* Get MIME type from file extension
|
||||
* @param filename - The filename or extension (with or without leading dot)
|
||||
* @returns MIME type string, defaults to 'application/octet-stream' if unknown
|
||||
*/
|
||||
export function getMimeType(filename: string): string {
|
||||
if (!filename) {
|
||||
return "application/octet-stream";
|
||||
}
|
||||
|
||||
let extension: string;
|
||||
|
||||
if (filename.startsWith(".")) {
|
||||
extension = filename.toLowerCase();
|
||||
} else if (!filename.includes(".")) {
|
||||
extension = "." + filename.toLowerCase();
|
||||
} else {
|
||||
const lastDotIndex = filename.lastIndexOf(".");
|
||||
if (lastDotIndex === -1) {
|
||||
return "application/octet-stream";
|
||||
}
|
||||
extension = filename.substring(lastDotIndex).toLowerCase();
|
||||
}
|
||||
|
||||
return mimeTypeMap[extension] || "application/octet-stream";
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a MIME type represents an image
|
||||
* @param mimeType - The MIME type to check
|
||||
* @returns true if the MIME type is an image type
|
||||
*/
|
||||
export function isImageMimeType(mimeType: string): boolean {
|
||||
return mimeType.startsWith("image/");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get appropriate Content-Type header value for a file
|
||||
* @param filename - The filename to detect type for
|
||||
* @returns Content-Type header value
|
||||
*/
|
||||
export function getContentType(filename: string): string {
|
||||
return getMimeType(filename);
|
||||
}
|
@@ -1,2 +1,5 @@
|
||||
API_BASE_URL=http:localhost:3333
|
||||
NEXT_PUBLIC_DEFAULT_LANGUAGE=en-US
|
||||
NEXT_PUBLIC_DEFAULT_LANGUAGE=en-US
|
||||
|
||||
# Configuration options
|
||||
NEXT_PUBLIC_UPLOAD_CHUNK_SIZE_MB=
|
@@ -144,7 +144,15 @@
|
||||
"update": "تحديث",
|
||||
"click": "انقر على",
|
||||
"creating": "جاري الإنشاء...",
|
||||
"loadingSimple": "جاري التحميل..."
|
||||
"loadingSimple": "جاري التحميل...",
|
||||
"create": "إنشاء",
|
||||
"deleting": "جاري الحذف...",
|
||||
"move": "نقل",
|
||||
"rename": "إعادة تسمية",
|
||||
"search": "بحث",
|
||||
"share": "مشاركة",
|
||||
"copied": "تم النسخ",
|
||||
"copy": "نسخ"
|
||||
},
|
||||
"createShare": {
|
||||
"title": "إنشاء مشاركة",
|
||||
@@ -159,7 +167,54 @@
|
||||
"passwordLabel": "كلمة المرور",
|
||||
"create": "إنشاء مشاركة",
|
||||
"success": "تم إنشاء المشاركة بنجاح",
|
||||
"error": "فشل في إنشاء المشاركة"
|
||||
"error": "فشل في إنشاء المشاركة",
|
||||
"namePlaceholder": "أدخل اسمًا لمشاركتك",
|
||||
"nextSelectFiles": "التالي: اختيار الملفات",
|
||||
"searchLabel": "بحث",
|
||||
"tabs": {
|
||||
"shareDetails": "تفاصيل المشاركة",
|
||||
"selectFiles": "اختيار الملفات"
|
||||
}
|
||||
},
|
||||
"customization": {
|
||||
"breadcrumb": "التخصيص",
|
||||
"colors": {
|
||||
"title": "ألوان السمة",
|
||||
"description": "اختر لون السمة الرئيسي المفضل لديك",
|
||||
"presets": "الألوان المتاحة",
|
||||
"presetsDescription": "اختر من بين السمات اللونية المتاحة",
|
||||
"reset": "إعادة التعيين إلى الافتراضي"
|
||||
},
|
||||
"fonts": {
|
||||
"title": "الخطوط",
|
||||
"description": "اختر عائلة الخط المفضلة لديك",
|
||||
"available": "الخطوط المتاحة",
|
||||
"availableDescription": "اختر من بين عائلات الخطوط المتاحة",
|
||||
"reset": "إعادة التعيين إلى الافتراضي"
|
||||
},
|
||||
"radius": {
|
||||
"title": "حواف الإطار",
|
||||
"description": "تخصيص استدارة عناصر الواجهة",
|
||||
"available": "خيارات الاستدارة",
|
||||
"availableDescription": "اختر كيف يجب أن تظهر الزوايا المستديرة",
|
||||
"reset": "إعادة التعيين إلى الافتراضي"
|
||||
},
|
||||
"background": {
|
||||
"title": "ألوان الخلفية",
|
||||
"description": "تخصيص ألوان الخلفية للوضعين الفاتح والداكن",
|
||||
"lightMode": "الوضع الفاتح",
|
||||
"darkMode": "الوضع الداكن",
|
||||
"availableDescription": "اختر ألوان الخلفية لكل من السمات الفاتحة والداكنة",
|
||||
"reset": "إعادة التعيين إلى الافتراضي"
|
||||
},
|
||||
"theme": {
|
||||
"title": "وضع السمة",
|
||||
"description": "اختر بين السمة الفاتحة أو الداكنة أو سمة النظام",
|
||||
"selectTheme": "تفضيلات السمة",
|
||||
"availableDescription": "حدد وضع السمة المفضل لديك",
|
||||
"reset": "إعادة التعيين إلى النظام"
|
||||
},
|
||||
"pageTitle": "التخصيص"
|
||||
},
|
||||
"dashboard": {
|
||||
"loadError": "فشل في تحميل بيانات لوحة التحكم",
|
||||
@@ -173,7 +228,42 @@
|
||||
},
|
||||
"deleteConfirmation": {
|
||||
"filesToDelete": "الملفات المراد حذفها",
|
||||
"sharesToDelete": "المشاركات التي سيتم حذفها"
|
||||
"sharesToDelete": "المشاركات التي سيتم حذفها",
|
||||
"foldersToDelete": "المجلدات المراد حذفها",
|
||||
"itemsToDelete": "العناصر المراد حذفها"
|
||||
},
|
||||
"downloadQueue": {
|
||||
"downloadQueued": "تم إضافة التنزيل إلى قائمة الانتظار: {fileName}",
|
||||
"queuedDescription": "سيبدأ التنزيل تلقائياً عندما يتوفر موقع",
|
||||
"queuePosition": "التنزيل في قائمة الانتظار في الموقع {position}: {fileName}",
|
||||
"estimatedWait": "وقت الانتظار المقدر: {time}",
|
||||
"queueFull": "قائمة انتظار التنزيل ممتلئة",
|
||||
"queueFullDescription": "يرجى المحاولة مرة أخرى بعد بضع دقائق عندما تتوفر مساحة في قائمة الانتظار",
|
||||
"cancelSuccess": "تم إلغاء التنزيل بنجاح",
|
||||
"cancelError": "فشل إلغاء التنزيل: {error}",
|
||||
"status": {
|
||||
"pending": "جارٍ التحضير...",
|
||||
"queued": "في قائمة الانتظار",
|
||||
"downloading": "جارٍ التنزيل",
|
||||
"completed": "مكتمل",
|
||||
"failed": "فشل"
|
||||
},
|
||||
"waitTime": {
|
||||
"seconds": "{seconds} ثانية",
|
||||
"minutes": "{minutes} دقيقة",
|
||||
"hoursMinutes": "{hours} ساعة {minutes} دقيقة"
|
||||
},
|
||||
"indicator": {
|
||||
"title": "التنزيلات",
|
||||
"downloads": "قائمة التنزيل",
|
||||
"active": "نشط",
|
||||
"queued": "في قائمة الانتظار",
|
||||
"position": "الموقع {position}",
|
||||
"estimatedWait": "الانتظار: {time}",
|
||||
"unknownFile": "ملف غير معروف",
|
||||
"noDownloads": "لا توجد تنزيلات قيد التقدم",
|
||||
"refresh": "تحديث قائمة الانتظار"
|
||||
}
|
||||
},
|
||||
"emptyState": {
|
||||
"noFiles": "لم يتم رفع أي ملفات بعد",
|
||||
@@ -202,7 +292,8 @@
|
||||
"descriptionPlaceholder": "أدخل وصف الملف",
|
||||
"deleteFile": "حذف الملف",
|
||||
"deleteConfirmation": "هل أنت متأكد أنك تريد حذف ؟",
|
||||
"deleteWarning": "هذا الإجراء لا يمكن التراجع عنه."
|
||||
"deleteWarning": "هذا الإجراء لا يمكن التراجع عنه.",
|
||||
"addDescriptionPlaceholder": "إضافة وصف..."
|
||||
},
|
||||
"fileManager": {
|
||||
"downloadError": "فشل في تنزيل الملف",
|
||||
@@ -213,6 +304,7 @@
|
||||
},
|
||||
"filePreview": {
|
||||
"title": "معاينة الملف",
|
||||
"description": "معاينة وتنزيل الملف",
|
||||
"loading": "جاري التحميل...",
|
||||
"notAvailable": "المعاينة غير متاحة لهذا النوع من الملفات.",
|
||||
"downloadToView": "استخدم زر التحميل لتنزيل الملف.",
|
||||
@@ -247,7 +339,8 @@
|
||||
"previewFile": "معاينة الملف",
|
||||
"addToShare": "إضافة إلى المشاركة",
|
||||
"removeFromShare": "إزالة من المشاركة",
|
||||
"saveChanges": "حفظ التغييرات"
|
||||
"saveChanges": "حفظ التغييرات",
|
||||
"editFolder": "تحرير المجلد"
|
||||
},
|
||||
"files": {
|
||||
"title": "جميع الملفات",
|
||||
@@ -270,7 +363,20 @@
|
||||
"table": "جدول",
|
||||
"grid": "شبكة"
|
||||
},
|
||||
"totalFiles": "{count, plural, =0 {لا توجد ملفات} =1 {ملف واحد} other {# ملفات}}"
|
||||
"totalFiles": "{count, plural, =0 {لا توجد ملفات} =1 {ملف واحد} other {# ملفات}}",
|
||||
"bulkDeleteConfirmation": "هل أنت متأكد من رغبتك في حذف {count, plural, =1 {ملف واحد} other {# ملفات}}؟ لا يمكن التراجع عن هذا الإجراء.",
|
||||
"bulkDeleteTitle": "حذف الملفات المحددة",
|
||||
"actions": {
|
||||
"open": "فتح",
|
||||
"rename": "إعادة تسمية",
|
||||
"delete": "حذف"
|
||||
},
|
||||
"empty": {
|
||||
"title": "لا توجد ملفات أو مجلدات بعد",
|
||||
"description": "ارفع ملفك الأول أو أنشئ مجلدًا للبدء"
|
||||
},
|
||||
"files": "ملفات",
|
||||
"folders": "مجلدات"
|
||||
},
|
||||
"filesTable": {
|
||||
"ariaLabel": "جدول الملفات",
|
||||
@@ -300,6 +406,33 @@
|
||||
"delete": "حذف المحدد"
|
||||
}
|
||||
},
|
||||
"folderActions": {
|
||||
"editFolder": "تحرير المجلد",
|
||||
"folderName": "اسم المجلد",
|
||||
"folderNamePlaceholder": "أدخل اسم المجلد",
|
||||
"folderDescription": "الوصف",
|
||||
"folderDescriptionPlaceholder": "أدخل وصف المجلد (اختياري)",
|
||||
"createFolder": "إنشاء مجلد جديد",
|
||||
"renameFolder": "إعادة تسمية المجلد",
|
||||
"moveFolder": "نقل المجلد",
|
||||
"shareFolder": "مشاركة المجلد",
|
||||
"deleteFolder": "حذف المجلد",
|
||||
"moveTo": "نقل إلى",
|
||||
"selectDestination": "اختر مجلد الوجهة",
|
||||
"rootFolder": "الجذر",
|
||||
"folderCreated": "تم إنشاء المجلد بنجاح",
|
||||
"folderRenamed": "تم إعادة تسمية المجلد بنجاح",
|
||||
"folderMoved": "تم نقل المجلد بنجاح",
|
||||
"folderDeleted": "تم حذف المجلد بنجاح",
|
||||
"folderShared": "تم مشاركة المجلد بنجاح",
|
||||
"createFolderError": "خطأ في إنشاء المجلد",
|
||||
"renameFolderError": "خطأ في إعادة تسمية المجلد",
|
||||
"moveFolderError": "خطأ في نقل المجلد",
|
||||
"deleteFolderError": "خطأ في حذف المجلد",
|
||||
"shareFolderError": "خطأ في مشاركة المجلد",
|
||||
"deleteConfirmation": "هل أنت متأكد من أنك تريد حذف هذا المجلد؟",
|
||||
"deleteWarning": "لا يمكن التراجع عن هذا الإجراء."
|
||||
},
|
||||
"footer": {
|
||||
"poweredBy": "مدعوم من",
|
||||
"kyanHomepage": "الصفحة الرئيسية لـ Kyantech"
|
||||
@@ -401,17 +534,43 @@
|
||||
"removeFailed": "فشل في حذف الشعار"
|
||||
}
|
||||
},
|
||||
"moveItems": {
|
||||
"itemsToMove": "العناصر المراد نقلها:",
|
||||
"movingTo": "النقل إلى:",
|
||||
"title": "نقل {count, plural, =1 {عنصر} other {عناصر}}",
|
||||
"description": "نقل {count, plural, =1 {عنصر} other {عناصر}} إلى موقع جديد",
|
||||
"success": "تم نقل {count} {count, plural, =1 {عنصر} other {عناصر}} بنجاح"
|
||||
},
|
||||
"navbar": {
|
||||
"logoAlt": "شعار التطبيق",
|
||||
"profileMenu": "قائمة الملف الشخصي",
|
||||
"profile": "الملف الشخصي",
|
||||
"settings": "الإعدادات",
|
||||
"usersManagement": "إدارة المستخدمين",
|
||||
"logout": "تسجيل الخروج"
|
||||
"logout": "تسجيل الخروج",
|
||||
"customization": "التخصيص"
|
||||
},
|
||||
"navigation": {
|
||||
"dashboard": "لوحة التحكم"
|
||||
},
|
||||
"notifications": {
|
||||
"permissionGranted": "تم تمكين إشعارات التنزيل",
|
||||
"permissionDenied": "تم تعطيل إشعارات التنزيل",
|
||||
"downloadComplete": {
|
||||
"title": "اكتمل التنزيل",
|
||||
"body": "اكتمل تنزيل {fileName}"
|
||||
},
|
||||
"downloadFailed": {
|
||||
"title": "فشل التنزيل",
|
||||
"body": "فشل تنزيل {fileName}: {error}",
|
||||
"unknownError": "خطأ غير معروف"
|
||||
},
|
||||
"queueProcessing": {
|
||||
"title": "بدء التنزيل",
|
||||
"body": "يتم الآن تنزيل {fileName}{position}",
|
||||
"position": " (كان #{position} في قائمة الانتظار)"
|
||||
}
|
||||
},
|
||||
"profile": {
|
||||
"password": {
|
||||
"title": "تغيير كلمة المرور",
|
||||
@@ -454,6 +613,11 @@
|
||||
},
|
||||
"pageTitle": "الملف الشخصي"
|
||||
},
|
||||
"qrCodeModal": {
|
||||
"title": "مشاركة رمز QR",
|
||||
"description": "امسح رمز QR هذا للوصول إلى الرابط.",
|
||||
"download": "تحميل رمز QR"
|
||||
},
|
||||
"quickAccess": {
|
||||
"files": {
|
||||
"title": "ملفاتي",
|
||||
@@ -789,7 +953,8 @@
|
||||
"timeout": "انتهت مهلة عملية النسخ. يرجى المحاولة مرة أخرى باستخدام ملف أصغر أو التحقق من اتصالك.",
|
||||
"failed": "فشلت عملية النسخ. يرجى المحاولة مرة أخرى.",
|
||||
"aborted": "تم إلغاء عملية النسخ بسبب انتهاء المهلة."
|
||||
}
|
||||
},
|
||||
"invalidDate": "تاريخ غير صحيح"
|
||||
}
|
||||
},
|
||||
"form": {
|
||||
@@ -894,7 +1059,8 @@
|
||||
"upload": {
|
||||
"metadata": {
|
||||
"title": "رفع الملفات - Palmr",
|
||||
"description": "رفع الملفات عبر الرابط المشترك"
|
||||
"description": "رفع الملفات عبر الرابط المشترك",
|
||||
"descriptionWithLimit": "تحميل الملفات (الحد الأقصى {limit} ملفات)"
|
||||
},
|
||||
"layout": {
|
||||
"defaultTitle": "رفع الملفات",
|
||||
@@ -1006,7 +1172,10 @@
|
||||
},
|
||||
"searchBar": {
|
||||
"placeholder": "ابحث عن الملفات...",
|
||||
"results": "تم العثور على {filtered} من {total} ملف"
|
||||
"results": "تم العثور على {filtered} من {total} ملف",
|
||||
"placeholderFolders": "البحث في المجلدات...",
|
||||
"noResults": "لم يتم العثور على نتائج لـ \"{query}\"",
|
||||
"placeholderFiles": "البحث في الملفات..."
|
||||
},
|
||||
"settings": {
|
||||
"groups": {
|
||||
@@ -1135,6 +1304,10 @@
|
||||
"passwordAuthEnabled": {
|
||||
"title": "المصادقة بالكلمة السرية",
|
||||
"description": "تمكين أو تعطيل المصادقة بالكلمة السرية"
|
||||
},
|
||||
"hideVersion": {
|
||||
"title": "إخفاء الإصدار",
|
||||
"description": "إخفاء إصدار Palmr في تذييل جميع الصفحات"
|
||||
}
|
||||
},
|
||||
"buttons": {
|
||||
@@ -1196,7 +1369,11 @@
|
||||
"description": "قد يكون تم حذف هذه المشاركة أو انتهت صلاحيتها."
|
||||
},
|
||||
"pageTitle": "المشاركة",
|
||||
"downloadAll": "تحميل الكل"
|
||||
"downloadAll": "تحميل الكل",
|
||||
"metadata": {
|
||||
"defaultDescription": "مشاركة الملفات بشكل آمن",
|
||||
"filesShared": "{count, plural, =1 {ملف واحد تمت مشاركته} other {# ملفات تمت مشاركتها}}"
|
||||
}
|
||||
},
|
||||
"shareActions": {
|
||||
"deleteTitle": "حذف المشاركة",
|
||||
@@ -1219,7 +1396,18 @@
|
||||
"editSuccess": "تم تحديث المشاركة بنجاح",
|
||||
"editError": "فشل في تحديث المشاركة",
|
||||
"bulkDeleteConfirmation": "هل أنت متأكد من أنك تريد حذف {count, plural, =1 {مشاركة واحدة} other {# مشاركات}} محددة؟ لا يمكن التراجع عن هذا الإجراء.",
|
||||
"bulkDeleteTitle": "حذف المشاركات المحددة"
|
||||
"bulkDeleteTitle": "حذف المشاركات المحددة",
|
||||
"addDescriptionPlaceholder": "إضافة وصف...",
|
||||
"aliasLabel": "اسم مستعار للرابط",
|
||||
"aliasPlaceholder": "أدخل اسمًا مستعارًا مخصصًا",
|
||||
"copyLink": "نسخ الرابط",
|
||||
"fileTitle": "مشاركة ملف",
|
||||
"folderTitle": "مشاركة مجلد",
|
||||
"generateLink": "إنشاء رابط",
|
||||
"linkDescriptionFile": "إنشاء رابط مخصص لمشاركة الملف",
|
||||
"linkDescriptionFolder": "إنشاء رابط مخصص لمشاركة المجلد",
|
||||
"linkReady": "رابط المشاركة جاهز:",
|
||||
"linkTitle": "إنشاء رابط"
|
||||
},
|
||||
"shareDetails": {
|
||||
"title": "تفاصيل المشاركة",
|
||||
@@ -1346,7 +1534,8 @@
|
||||
"files": "ملفات",
|
||||
"totalSize": "الحجم الإجمالي",
|
||||
"creating": "جاري الإنشاء...",
|
||||
"create": "إنشاء مشاركة"
|
||||
"create": "إنشاء مشاركة",
|
||||
"itemsToShare": "العناصر للمشاركة ({count} {count, plural, =1 {عنصر} other {عناصر}})"
|
||||
},
|
||||
"shareSecurity": {
|
||||
"subtitle": "تكوين حماية كلمة المرور وخيارات الأمان لهذه المشاركة",
|
||||
@@ -1451,7 +1640,8 @@
|
||||
"download": "تنزيل محدد"
|
||||
},
|
||||
"selectAll": "تحديد الكل",
|
||||
"selectShare": "تحديد المشاركة {shareName}"
|
||||
"selectShare": "تحديد المشاركة {shareName}",
|
||||
"folderCount": "مجلدات"
|
||||
},
|
||||
"storageUsage": {
|
||||
"title": "استخدام التخزين",
|
||||
@@ -1659,7 +1849,8 @@
|
||||
"title": "إفلات الملفات للرفع",
|
||||
"description": "حرر للرفع ملفاتك"
|
||||
},
|
||||
"pasteSuccess": "{count, plural, =1 {تم لصق الصورة ورفعها بنجاح} other {تم لصق # صور ورفعها بنجاح}}"
|
||||
"pasteSuccess": "{count, plural, =1 {تم لصق الصورة ورفعها بنجاح} other {تم لصق # صور ورفعها بنجاح}}",
|
||||
"filesQueued": "{count, plural, one {# ملف في الصف} other {# ملفات في الصف}}"
|
||||
},
|
||||
"users": {
|
||||
"modes": {
|
||||
@@ -1745,9 +1936,16 @@
|
||||
"nameRequired": "الاسم مطلوب",
|
||||
"required": "هذا الحقل مطلوب"
|
||||
},
|
||||
"qrCodeModal": {
|
||||
"title": "مشاركة رمز QR",
|
||||
"description": "امسح رمز QR هذا للوصول إلى الرابط.",
|
||||
"download": "تحميل رمز QR"
|
||||
"embedCode": {
|
||||
"title": "تضمين الصورة",
|
||||
"description": "استخدم هذه الأكواد لتضمين هذه الصورة في المنتديات أو المواقع الإلكترونية أو المنصات الأخرى",
|
||||
"tabs": {
|
||||
"directLink": "رابط مباشر",
|
||||
"html": "HTML",
|
||||
"bbcode": "BBCode"
|
||||
},
|
||||
"directLinkDescription": "عنوان URL مباشر لملف الصورة",
|
||||
"htmlDescription": "استخدم هذا الكود لتضمين الصورة في صفحات HTML",
|
||||
"bbcodeDescription": "استخدم هذا الكود لتضمين الصورة في المنتديات التي تدعم BBCode"
|
||||
}
|
||||
}
|
@@ -144,7 +144,15 @@
|
||||
"update": "Aktualisieren",
|
||||
"click": "Klicken Sie auf",
|
||||
"creating": "Erstellen...",
|
||||
"loadingSimple": "Lade..."
|
||||
"loadingSimple": "Lade...",
|
||||
"create": "Erstellen",
|
||||
"deleting": "Lösche...",
|
||||
"move": "Verschieben",
|
||||
"rename": "Umbenennen",
|
||||
"search": "Suchen",
|
||||
"share": "Teilen",
|
||||
"copied": "Kopiert",
|
||||
"copy": "Kopieren"
|
||||
},
|
||||
"createShare": {
|
||||
"title": "Freigabe Erstellen",
|
||||
@@ -159,7 +167,54 @@
|
||||
"passwordLabel": "Passwort",
|
||||
"create": "Freigabe Erstellen",
|
||||
"success": "Freigabe erfolgreich erstellt",
|
||||
"error": "Fehler beim Erstellen der Freigabe"
|
||||
"error": "Fehler beim Erstellen der Freigabe",
|
||||
"namePlaceholder": "Geben Sie einen Namen für Ihre Freigabe ein",
|
||||
"nextSelectFiles": "Weiter: Dateien auswählen",
|
||||
"searchLabel": "Suchen",
|
||||
"tabs": {
|
||||
"shareDetails": "Freigabe-Details",
|
||||
"selectFiles": "Dateien auswählen"
|
||||
}
|
||||
},
|
||||
"customization": {
|
||||
"breadcrumb": "Anpassung",
|
||||
"colors": {
|
||||
"title": "Farbthema",
|
||||
"description": "Wählen Sie Ihre bevorzugte Primärfarbe für das Theme",
|
||||
"presets": "Verfügbare Farben",
|
||||
"presetsDescription": "Wählen Sie aus verfügbaren Farbthemen",
|
||||
"reset": "Auf Standard zurücksetzen"
|
||||
},
|
||||
"fonts": {
|
||||
"title": "Typografie",
|
||||
"description": "Wählen Sie Ihre bevorzugte Schriftart",
|
||||
"available": "Verfügbare Schriftarten",
|
||||
"availableDescription": "Wählen Sie aus verfügbaren Schriftfamilien",
|
||||
"reset": "Auf Standard zurücksetzen"
|
||||
},
|
||||
"radius": {
|
||||
"title": "Rahmenradius",
|
||||
"description": "Passen Sie die Rundung der Oberflächenelemente an",
|
||||
"available": "Rundungsoptionen",
|
||||
"availableDescription": "Wählen Sie, wie abgerundet die Ecken erscheinen sollen",
|
||||
"reset": "Auf Standard zurücksetzen"
|
||||
},
|
||||
"background": {
|
||||
"title": "Hintergrundfarben",
|
||||
"description": "Passen Sie Hintergrundfarben für Hell- und Dunkelmodus an",
|
||||
"lightMode": "Hellmodus",
|
||||
"darkMode": "Dunkelmodus",
|
||||
"availableDescription": "Wählen Sie Hintergrundfarben für helle und dunkle Themes",
|
||||
"reset": "Auf Standard zurücksetzen"
|
||||
},
|
||||
"theme": {
|
||||
"title": "Themenmodus",
|
||||
"description": "Wählen Sie zwischen hellem, dunklem oder Systemmodus",
|
||||
"selectTheme": "Theme-Einstellung",
|
||||
"availableDescription": "Wählen Sie Ihren bevorzugten Themenmodus",
|
||||
"reset": "Auf System zurücksetzen"
|
||||
},
|
||||
"pageTitle": "Anpassung"
|
||||
},
|
||||
"dashboard": {
|
||||
"loadError": "Fehler beim Laden der Dashboard-Daten",
|
||||
@@ -173,7 +228,42 @@
|
||||
},
|
||||
"deleteConfirmation": {
|
||||
"filesToDelete": "Zu löschende Dateien",
|
||||
"sharesToDelete": "Freigaben, die gelöscht werden"
|
||||
"sharesToDelete": "Freigaben, die gelöscht werden",
|
||||
"foldersToDelete": "Zu löschende Ordner",
|
||||
"itemsToDelete": "Zu löschende Elemente"
|
||||
},
|
||||
"downloadQueue": {
|
||||
"downloadQueued": "Download in Warteschlange: {fileName}",
|
||||
"queuedDescription": "Ihr Download startet automatisch, sobald ein Platz frei wird",
|
||||
"queuePosition": "Download an Position {position} in der Warteschlange: {fileName}",
|
||||
"estimatedWait": "Geschätzte Wartezeit: {time}",
|
||||
"queueFull": "Download-Warteschlange ist voll",
|
||||
"queueFullDescription": "Bitte versuchen Sie es in einigen Minuten erneut, wenn die Warteschlange Platz hat",
|
||||
"cancelSuccess": "Download erfolgreich abgebrochen",
|
||||
"cancelError": "Download konnte nicht abgebrochen werden: {error}",
|
||||
"status": {
|
||||
"pending": "Wird vorbereitet...",
|
||||
"queued": "In Warteschlange",
|
||||
"downloading": "Wird heruntergeladen",
|
||||
"completed": "Abgeschlossen",
|
||||
"failed": "Fehlgeschlagen"
|
||||
},
|
||||
"waitTime": {
|
||||
"seconds": "{seconds}s",
|
||||
"minutes": "{minutes}m",
|
||||
"hoursMinutes": "{hours}h {minutes}m"
|
||||
},
|
||||
"indicator": {
|
||||
"title": "Downloads",
|
||||
"downloads": "Download-Warteschlange",
|
||||
"active": "Aktiv",
|
||||
"queued": "In Warteschlange",
|
||||
"position": "Position {position}",
|
||||
"estimatedWait": "Wartezeit: {time}",
|
||||
"unknownFile": "Unbekannte Datei",
|
||||
"noDownloads": "Keine laufenden Downloads",
|
||||
"refresh": "Warteschlange aktualisieren"
|
||||
}
|
||||
},
|
||||
"emptyState": {
|
||||
"noFiles": "Noch keine Dateien hochgeladen",
|
||||
@@ -200,6 +290,7 @@
|
||||
"extension": "Erweiterung",
|
||||
"descriptionLabel": "Beschreibung",
|
||||
"descriptionPlaceholder": "Dateibeschreibung eingeben",
|
||||
"addDescriptionPlaceholder": "Beschreibung hinzufügen...",
|
||||
"deleteFile": "Datei löschen",
|
||||
"deleteConfirmation": "Sind Sie sicher, dass Sie löschen möchten?",
|
||||
"deleteWarning": "Diese Aktion kann nicht rückgängig gemacht werden."
|
||||
@@ -213,6 +304,7 @@
|
||||
},
|
||||
"filePreview": {
|
||||
"title": "Datei-Vorschau",
|
||||
"description": "Vorschau und Download der Datei",
|
||||
"loading": "Laden...",
|
||||
"notAvailable": "Vorschau für diesen Dateityp nicht verfügbar.",
|
||||
"downloadToView": "Verwenden Sie die Download-Schaltfläche, um die Datei herunterzuladen.",
|
||||
@@ -247,7 +339,8 @@
|
||||
"previewFile": "Datei-Vorschau",
|
||||
"addToShare": "Zur Freigabe hinzufügen",
|
||||
"removeFromShare": "Aus Freigabe entfernen",
|
||||
"saveChanges": "Änderungen Speichern"
|
||||
"saveChanges": "Änderungen Speichern",
|
||||
"editFolder": "Ordner bearbeiten"
|
||||
},
|
||||
"files": {
|
||||
"title": "Alle Dateien",
|
||||
@@ -266,11 +359,24 @@
|
||||
"bulkDownloadFileError": "Fehler beim Herunterladen der Datei {fileName}",
|
||||
"bulkDeleteSuccess": "{count, plural, =1 {1 Datei erfolgreich gelöscht} other {# Dateien erfolgreich gelöscht}}",
|
||||
"bulkDeleteError": "Fehler beim Löschen der ausgewählten Dateien",
|
||||
"bulkDeleteTitle": "Ausgewählte Dateien Löschen",
|
||||
"bulkDeleteConfirmation": "Sind Sie sicher, dass Sie {count, plural, =1 {1 Datei} other {# Dateien}} löschen möchten? Diese Aktion kann nicht rückgängig gemacht werden.",
|
||||
"viewMode": {
|
||||
"table": "Tabelle",
|
||||
"grid": "Raster"
|
||||
},
|
||||
"totalFiles": "{count, plural, =0 {Keine Dateien} =1 {1 Datei} other {# Dateien}}"
|
||||
"totalFiles": "{count, plural, =0 {Keine Dateien} =1 {1 Datei} other {# Dateien}}",
|
||||
"actions": {
|
||||
"open": "Öffnen",
|
||||
"rename": "Umbenennen",
|
||||
"delete": "Löschen"
|
||||
},
|
||||
"empty": {
|
||||
"title": "Noch keine Dateien oder Ordner",
|
||||
"description": "Laden Sie Ihre erste Datei hoch oder erstellen Sie einen Ordner, um zu beginnen"
|
||||
},
|
||||
"files": "Dateien",
|
||||
"folders": "Ordner"
|
||||
},
|
||||
"filesTable": {
|
||||
"ariaLabel": "Dateien-Tabelle",
|
||||
@@ -300,6 +406,33 @@
|
||||
"delete": "Ausgewählte Löschen"
|
||||
}
|
||||
},
|
||||
"folderActions": {
|
||||
"editFolder": "Ordner bearbeiten",
|
||||
"folderName": "Ordnername",
|
||||
"folderNamePlaceholder": "Ordnername eingeben",
|
||||
"folderDescription": "Beschreibung",
|
||||
"folderDescriptionPlaceholder": "Ordnerbeschreibung eingeben (optional)",
|
||||
"createFolder": "Neuen Ordner erstellen",
|
||||
"renameFolder": "Ordner umbenennen",
|
||||
"moveFolder": "Ordner verschieben",
|
||||
"shareFolder": "Ordner teilen",
|
||||
"deleteFolder": "Ordner löschen",
|
||||
"moveTo": "Verschieben nach",
|
||||
"selectDestination": "Zielordner auswählen",
|
||||
"rootFolder": "Stammordner",
|
||||
"folderCreated": "Ordner erfolgreich erstellt",
|
||||
"folderRenamed": "Ordner erfolgreich umbenannt",
|
||||
"folderMoved": "Ordner erfolgreich verschoben",
|
||||
"folderDeleted": "Ordner erfolgreich gelöscht",
|
||||
"folderShared": "Ordner erfolgreich geteilt",
|
||||
"createFolderError": "Fehler beim Erstellen des Ordners",
|
||||
"renameFolderError": "Fehler beim Umbenennen des Ordners",
|
||||
"moveFolderError": "Fehler beim Verschieben des Ordners",
|
||||
"deleteFolderError": "Fehler beim Löschen des Ordners",
|
||||
"shareFolderError": "Fehler beim Teilen des Ordners",
|
||||
"deleteConfirmation": "Sind Sie sicher, dass Sie diesen Ordner löschen möchten?",
|
||||
"deleteWarning": "Diese Aktion kann nicht rückgängig gemacht werden."
|
||||
},
|
||||
"footer": {
|
||||
"poweredBy": "Angetrieben von",
|
||||
"kyanHomepage": "Kyantech Homepage"
|
||||
@@ -401,17 +534,43 @@
|
||||
"removeFailed": "Fehler beim Entfernen des Logos"
|
||||
}
|
||||
},
|
||||
"moveItems": {
|
||||
"itemsToMove": "Zu verschiebende Elemente:",
|
||||
"movingTo": "Verschieben nach:",
|
||||
"title": "{count, plural, =1 {Element} other {Elemente}} verschieben",
|
||||
"description": "{count, plural, =1 {Element} other {Elemente}} an einen neuen Ort verschieben",
|
||||
"success": "Erfolgreich {count} {count, plural, =1 {Element} other {Elemente}} verschoben"
|
||||
},
|
||||
"navbar": {
|
||||
"logoAlt": "Anwendungslogo",
|
||||
"profileMenu": "Profilmenü",
|
||||
"profile": "Profil",
|
||||
"settings": "Einstellungen",
|
||||
"usersManagement": "Benutzerverwaltung",
|
||||
"logout": "Abmelden"
|
||||
"logout": "Abmelden",
|
||||
"customization": "Anpassung"
|
||||
},
|
||||
"navigation": {
|
||||
"dashboard": "Übersicht"
|
||||
},
|
||||
"notifications": {
|
||||
"permissionGranted": "Download-Benachrichtigungen aktiviert",
|
||||
"permissionDenied": "Download-Benachrichtigungen deaktiviert",
|
||||
"downloadComplete": {
|
||||
"title": "Download abgeschlossen",
|
||||
"body": "{fileName} wurde erfolgreich heruntergeladen"
|
||||
},
|
||||
"downloadFailed": {
|
||||
"title": "Download fehlgeschlagen",
|
||||
"body": "Fehler beim Herunterladen von {fileName}: {error}",
|
||||
"unknownError": "Unbekannter Fehler"
|
||||
},
|
||||
"queueProcessing": {
|
||||
"title": "Download startet",
|
||||
"body": "{fileName} wird jetzt heruntergeladen{position}",
|
||||
"position": " (war #{position} in der Warteschlange)"
|
||||
}
|
||||
},
|
||||
"profile": {
|
||||
"password": {
|
||||
"title": "Passwort ändern",
|
||||
@@ -454,6 +613,11 @@
|
||||
},
|
||||
"pageTitle": "Profil"
|
||||
},
|
||||
"qrCodeModal": {
|
||||
"title": "QR-Code teilen",
|
||||
"description": "Scannen Sie diesen QR-Code, um auf den Link zuzugreifen.",
|
||||
"download": "QR-Code herunterladen"
|
||||
},
|
||||
"quickAccess": {
|
||||
"files": {
|
||||
"title": "Meine Dateien",
|
||||
@@ -744,6 +908,7 @@
|
||||
"noFiles": "Noch keine Dateien empfangen",
|
||||
"noFilesDescription": "Über diesen Link gesendete Dateien erscheinen hier",
|
||||
"fileCount": "{count, plural, =0 {Keine Dateien} =1 {1 Datei} other {# Dateien}}",
|
||||
"invalidDate": "Ungültiges Datum",
|
||||
"totalSize": "Gesamtgröße: {size}",
|
||||
"columns": {
|
||||
"file": "Datei",
|
||||
@@ -894,7 +1059,8 @@
|
||||
"upload": {
|
||||
"metadata": {
|
||||
"title": "Dateien senden - Palmr",
|
||||
"description": "Senden Sie Dateien über den geteilten Link"
|
||||
"description": "Senden Sie Dateien über den geteilten Link",
|
||||
"descriptionWithLimit": "Dateien hochladen (max. {limit} Dateien)"
|
||||
},
|
||||
"layout": {
|
||||
"defaultTitle": "Dateien senden",
|
||||
@@ -1004,7 +1170,10 @@
|
||||
},
|
||||
"searchBar": {
|
||||
"placeholder": "Dateien suchen...",
|
||||
"results": "Gefunden {filtered} von {total} Dateien"
|
||||
"results": "Gefunden {filtered} von {total} Dateien",
|
||||
"placeholderFolders": "Ordner durchsuchen...",
|
||||
"noResults": "Keine Ergebnisse für \"{query}\" gefunden",
|
||||
"placeholderFiles": "Dateien suchen..."
|
||||
},
|
||||
"settings": {
|
||||
"groups": {
|
||||
@@ -1133,6 +1302,10 @@
|
||||
"passwordAuthEnabled": {
|
||||
"title": "Passwort-Authentifizierung",
|
||||
"description": "Passwort-basierte Authentifizierung aktivieren oder deaktivieren"
|
||||
},
|
||||
"hideVersion": {
|
||||
"title": "Version Ausblenden",
|
||||
"description": "Die Palmr-Version in der Fußzeile aller Seiten ausblenden"
|
||||
}
|
||||
},
|
||||
"buttons": {
|
||||
@@ -1194,11 +1367,16 @@
|
||||
"description": "Diese Freigabe wurde möglicherweise gelöscht oder ist abgelaufen."
|
||||
},
|
||||
"pageTitle": "Freigabe",
|
||||
"downloadAll": "Alle herunterladen"
|
||||
"downloadAll": "Alle herunterladen",
|
||||
"metadata": {
|
||||
"defaultDescription": "Dateien sicher teilen",
|
||||
"filesShared": "{count, plural, =1 {1 Datei geteilt} other {# Dateien geteilt}}"
|
||||
}
|
||||
},
|
||||
"shareActions": {
|
||||
"deleteTitle": "Freigabe Löschen",
|
||||
"deleteConfirmation": "Sind Sie sicher, dass Sie diese Freigabe löschen möchten? Diese Aktion kann nicht rückgängig gemacht werden.",
|
||||
"addDescriptionPlaceholder": "Beschreibung hinzufügen...",
|
||||
"editTitle": "Freigabe Bearbeiten",
|
||||
"nameLabel": "Freigabe-Name",
|
||||
"descriptionLabel": "Beschreibung",
|
||||
@@ -1217,7 +1395,17 @@
|
||||
"editSuccess": "Freigabe erfolgreich aktualisiert",
|
||||
"editError": "Fehler beim Aktualisieren der Freigabe",
|
||||
"bulkDeleteConfirmation": "Sind Sie sicher, dass Sie {count, plural, =1 {1 Freigabe} other {# Freigaben}} löschen möchten? Diese Aktion kann nicht rückgängig gemacht werden.",
|
||||
"bulkDeleteTitle": "Ausgewählte Freigaben löschen"
|
||||
"bulkDeleteTitle": "Ausgewählte Freigaben löschen",
|
||||
"aliasLabel": "Link-Alias",
|
||||
"aliasPlaceholder": "Benutzerdefinierten Alias eingeben",
|
||||
"copyLink": "Link kopieren",
|
||||
"fileTitle": "Datei teilen",
|
||||
"folderTitle": "Ordner teilen",
|
||||
"generateLink": "Link generieren",
|
||||
"linkDescriptionFile": "Erstellen Sie einen benutzerdefinierten Link zum Teilen der Datei",
|
||||
"linkDescriptionFolder": "Erstellen Sie einen benutzerdefinierten Link zum Teilen des Ordners",
|
||||
"linkReady": "Ihr Freigabe-Link ist bereit:",
|
||||
"linkTitle": "Link generieren"
|
||||
},
|
||||
"shareDetails": {
|
||||
"title": "Freigabe-Details",
|
||||
@@ -1344,7 +1532,8 @@
|
||||
"files": "Dateien",
|
||||
"totalSize": "Gesamtgröße",
|
||||
"creating": "Erstellen...",
|
||||
"create": "Freigabe Erstellen"
|
||||
"create": "Freigabe Erstellen",
|
||||
"itemsToShare": "Zu teilende Elemente ({count} {count, plural, =1 {Element} other {Elemente}})"
|
||||
},
|
||||
"shareSecurity": {
|
||||
"subtitle": "Passwortschutz und Sicherheitsoptionen für diese Freigabe konfigurieren",
|
||||
@@ -1449,7 +1638,8 @@
|
||||
"download": "Download ausgewählt"
|
||||
},
|
||||
"selectAll": "Alle auswählen",
|
||||
"selectShare": "Freigabe {shareName} auswählen"
|
||||
"selectShare": "Freigabe {shareName} auswählen",
|
||||
"folderCount": "Ordner"
|
||||
},
|
||||
"storageUsage": {
|
||||
"title": "Speichernutzung",
|
||||
@@ -1657,7 +1847,8 @@
|
||||
"title": "Dateien zum Hochladen ablegen",
|
||||
"description": "Loslassen, um Ihre Dateien hochzuladen"
|
||||
},
|
||||
"pasteSuccess": "{count, plural, =1 {Bild erfolgreich eingefügt und hochgeladen} other {# Bilder erfolgreich eingefügt und hochgeladen}}"
|
||||
"pasteSuccess": "{count, plural, =1 {Bild erfolgreich eingefügt und hochgeladen} other {# Bilder erfolgreich eingefügt und hochgeladen}}",
|
||||
"filesQueued": "{count, plural, one {# Datei in der Warteschlange} other {# Dateien in der Warteschlange}}"
|
||||
},
|
||||
"users": {
|
||||
"modes": {
|
||||
@@ -1743,9 +1934,16 @@
|
||||
"nameRequired": "Name ist erforderlich",
|
||||
"required": "Dieses Feld ist erforderlich"
|
||||
},
|
||||
"qrCodeModal": {
|
||||
"title": "QR-Code teilen",
|
||||
"description": "Scannen Sie diesen QR-Code, um auf den Link zuzugreifen.",
|
||||
"download": "QR-Code herunterladen"
|
||||
"embedCode": {
|
||||
"title": "Bild einbetten",
|
||||
"description": "Verwenden Sie diese Codes, um dieses Bild in Foren, Websites oder anderen Plattformen einzubetten",
|
||||
"tabs": {
|
||||
"directLink": "Direkter Link",
|
||||
"html": "HTML",
|
||||
"bbcode": "BBCode"
|
||||
},
|
||||
"directLinkDescription": "Direkte URL zur Bilddatei",
|
||||
"htmlDescription": "Verwenden Sie diesen Code, um das Bild in HTML-Seiten einzubetten",
|
||||
"bbcodeDescription": "Verwenden Sie diesen Code, um das Bild in Foren einzubetten, die BBCode unterstützen"
|
||||
}
|
||||
}
|
@@ -136,6 +136,7 @@
|
||||
"update": "Update",
|
||||
"updating": "Updating...",
|
||||
"delete": "Delete",
|
||||
"deleting": "Deleting...",
|
||||
"close": "Close",
|
||||
"download": "Download",
|
||||
"unexpectedError": "An unexpected error occurred. Please try again.",
|
||||
@@ -144,11 +145,19 @@
|
||||
"dashboard": "Dashboard",
|
||||
"back": "Back",
|
||||
"click": "Click to",
|
||||
"creating": "Creating..."
|
||||
"creating": "Creating...",
|
||||
"create": "Create",
|
||||
"rename": "Rename",
|
||||
"move": "Move",
|
||||
"share": "Share",
|
||||
"search": "Search",
|
||||
"copy": "Copy",
|
||||
"copied": "Copied"
|
||||
},
|
||||
"createShare": {
|
||||
"title": "Create Share",
|
||||
"nameLabel": "Share Name",
|
||||
"namePlaceholder": "Enter a name for your share",
|
||||
"descriptionLabel": "Description",
|
||||
"descriptionPlaceholder": "Enter a description (optional)",
|
||||
"expirationLabel": "Expiration Date",
|
||||
@@ -159,7 +168,53 @@
|
||||
"passwordLabel": "Password",
|
||||
"create": "Create Share",
|
||||
"success": "Share created successfully",
|
||||
"error": "Failed to create share"
|
||||
"error": "Failed to create share",
|
||||
"tabs": {
|
||||
"shareDetails": "Share Details",
|
||||
"selectFiles": "Select Files"
|
||||
},
|
||||
"nextSelectFiles": "Next: Select Files",
|
||||
"searchLabel": "Search"
|
||||
},
|
||||
"customization": {
|
||||
"breadcrumb": "Customization",
|
||||
"colors": {
|
||||
"title": "Theme Colors",
|
||||
"description": "Choose your preferred primary color theme",
|
||||
"presets": "Available Colors",
|
||||
"presetsDescription": "Select from available color themes",
|
||||
"reset": "Reset to Default"
|
||||
},
|
||||
"fonts": {
|
||||
"title": "Typography",
|
||||
"description": "Choose your preferred font family",
|
||||
"available": "Available Fonts",
|
||||
"availableDescription": "Select from available font families",
|
||||
"reset": "Reset to Default"
|
||||
},
|
||||
"radius": {
|
||||
"title": "Border Radius",
|
||||
"description": "Customize the roundness of interface elements",
|
||||
"available": "Roundness Options",
|
||||
"availableDescription": "Choose how rounded corners should appear",
|
||||
"reset": "Reset to Default"
|
||||
},
|
||||
"background": {
|
||||
"title": "Background Colors",
|
||||
"description": "Customize background colors for light and dark modes",
|
||||
"lightMode": "Light Mode",
|
||||
"darkMode": "Dark Mode",
|
||||
"availableDescription": "Choose background colors for both light and dark themes",
|
||||
"reset": "Reset to Default"
|
||||
},
|
||||
"theme": {
|
||||
"title": "Theme Mode",
|
||||
"description": "Choose between light, dark, or system theme",
|
||||
"selectTheme": "Theme Preference",
|
||||
"availableDescription": "Select your preferred theme mode",
|
||||
"reset": "Reset to System"
|
||||
},
|
||||
"pageTitle": "Customization"
|
||||
},
|
||||
"dashboard": {
|
||||
"loadError": "Failed to load dashboard data",
|
||||
@@ -173,8 +228,43 @@
|
||||
},
|
||||
"deleteConfirmation": {
|
||||
"filesToDelete": "Files to be deleted",
|
||||
"foldersToDelete": "Folders to be deleted",
|
||||
"itemsToDelete": "Items to be deleted",
|
||||
"sharesToDelete": "Shares to be deleted"
|
||||
},
|
||||
"downloadQueue": {
|
||||
"downloadQueued": "Download queued: {fileName}",
|
||||
"queuedDescription": "Your download will start automatically when a slot becomes available",
|
||||
"queuePosition": "Download queued at position {position}: {fileName}",
|
||||
"estimatedWait": "Estimated wait time: {time}",
|
||||
"queueFull": "Download queue is full",
|
||||
"queueFullDescription": "Please try again in a few minutes when the queue has space",
|
||||
"cancelSuccess": "Download cancelled successfully",
|
||||
"cancelError": "Failed to cancel download: {error}",
|
||||
"status": {
|
||||
"pending": "Preparing...",
|
||||
"queued": "In queue",
|
||||
"downloading": "Downloading",
|
||||
"completed": "Completed",
|
||||
"failed": "Failed"
|
||||
},
|
||||
"waitTime": {
|
||||
"seconds": "{seconds}s",
|
||||
"minutes": "{minutes}m",
|
||||
"hoursMinutes": "{hours}h {minutes}m"
|
||||
},
|
||||
"indicator": {
|
||||
"title": "Downloads",
|
||||
"downloads": "Download Queue",
|
||||
"active": "Active",
|
||||
"queued": "Queued",
|
||||
"position": "Position {position}",
|
||||
"estimatedWait": "Wait: {time}",
|
||||
"unknownFile": "Unknown file",
|
||||
"noDownloads": "No downloads in progress",
|
||||
"refresh": "Refresh Queue"
|
||||
}
|
||||
},
|
||||
"emptyState": {
|
||||
"noFiles": "No files uploaded yet",
|
||||
"uploadFile": "Upload File"
|
||||
@@ -200,6 +290,7 @@
|
||||
"extension": "Extension",
|
||||
"descriptionLabel": "Description",
|
||||
"descriptionPlaceholder": "Enter file description",
|
||||
"addDescriptionPlaceholder": "Add description...",
|
||||
"deleteFile": "Delete File",
|
||||
"deleteConfirmation": "Are you sure you want to delete this file?",
|
||||
"deleteWarning": "This action cannot be undone."
|
||||
@@ -213,6 +304,7 @@
|
||||
},
|
||||
"filePreview": {
|
||||
"title": "Preview File",
|
||||
"description": "Preview and download file",
|
||||
"loading": "Loading...",
|
||||
"notAvailable": "Preview not available for this file type",
|
||||
"downloadToView": "Use the download button to view this file",
|
||||
@@ -244,6 +336,7 @@
|
||||
"fileCount": "{count, plural, =1 {file} other {files}}",
|
||||
"filesSelected": "{count, plural, =0 {No files selected} =1 {1 file selected} other {# files selected}}",
|
||||
"editFile": "Edit file",
|
||||
"editFolder": "Edit folder",
|
||||
"previewFile": "Preview file",
|
||||
"addToShare": "Add to share",
|
||||
"removeFromShare": "Remove from share",
|
||||
@@ -264,9 +357,22 @@
|
||||
"bulkDownloadSuccess": "Files download started successfully",
|
||||
"bulkDownloadError": "Error creating ZIP file",
|
||||
"bulkDownloadFileError": "Error downloading file {fileName}",
|
||||
"bulkDeleteSuccess": "{count, plural, =1 {1 file deleted successfully} other {# files deleted successfully}}",
|
||||
"bulkDeleteError": "Error deleting selected files",
|
||||
"bulkDeleteSuccess": "{count, plural, =1 {1 item deleted successfully} other {# items deleted successfully}}",
|
||||
"bulkDeleteError": "Error deleting selected items",
|
||||
"bulkDeleteTitle": "Delete Selected Items",
|
||||
"bulkDeleteConfirmation": "Are you sure you want to delete {count, plural, =1 {1 item} other {# items}}? This action cannot be undone.",
|
||||
"totalFiles": "{count, plural, =0 {No files} =1 {1 file} other {# files}}",
|
||||
"empty": {
|
||||
"title": "No files or folders yet",
|
||||
"description": "Upload your first file or create a folder to get started"
|
||||
},
|
||||
"files": "files",
|
||||
"folders": "folders",
|
||||
"actions": {
|
||||
"open": "Open",
|
||||
"rename": "Rename",
|
||||
"delete": "Delete"
|
||||
},
|
||||
"viewMode": {
|
||||
"table": "Table",
|
||||
"grid": "Grid"
|
||||
@@ -300,6 +406,33 @@
|
||||
"delete": "Delete Selected"
|
||||
}
|
||||
},
|
||||
"folderActions": {
|
||||
"editFolder": "Edit Folder",
|
||||
"folderName": "Folder Name",
|
||||
"folderNamePlaceholder": "Enter folder name",
|
||||
"folderDescription": "Description",
|
||||
"folderDescriptionPlaceholder": "Enter folder description (optional)",
|
||||
"createFolder": "Create Folder",
|
||||
"renameFolder": "Rename Folder",
|
||||
"moveFolder": "Move Folder",
|
||||
"shareFolder": "Share Folder",
|
||||
"deleteFolder": "Delete Folder",
|
||||
"moveTo": "Move to",
|
||||
"selectDestination": "Select destination folder",
|
||||
"rootFolder": "Root",
|
||||
"folderCreated": "Folder created successfully",
|
||||
"folderRenamed": "Folder renamed successfully",
|
||||
"folderMoved": "Folder moved successfully",
|
||||
"folderDeleted": "Folder deleted successfully",
|
||||
"folderShared": "Folder shared successfully",
|
||||
"createFolderError": "Error creating folder",
|
||||
"renameFolderError": "Error renaming folder",
|
||||
"moveFolderError": "Error moving folder",
|
||||
"deleteFolderError": "Error deleting folder",
|
||||
"shareFolderError": "Error sharing folder",
|
||||
"deleteConfirmation": "Are you sure you want to delete this folder?",
|
||||
"deleteWarning": "This action cannot be undone."
|
||||
},
|
||||
"footer": {
|
||||
"poweredBy": "Powered by",
|
||||
"kyanHomepage": "Kyantech homepage"
|
||||
@@ -401,10 +534,18 @@
|
||||
"removeFailed": "Failed to remove logo"
|
||||
}
|
||||
},
|
||||
"moveItems": {
|
||||
"itemsToMove": "Items to move:",
|
||||
"movingTo": "Moving to:",
|
||||
"title": "Move {count, plural, =1 {Item} other {Items}}",
|
||||
"description": "Move {count, plural, =1 {item} other {items}} to a new location",
|
||||
"success": "Successfully moved {count} {count, plural, =1 {item} other {items}}"
|
||||
},
|
||||
"navbar": {
|
||||
"logoAlt": "App Logo",
|
||||
"profileMenu": "Profile Menu",
|
||||
"profile": "Profile",
|
||||
"customization": "Customization",
|
||||
"settings": "Settings",
|
||||
"usersManagement": "User Management",
|
||||
"logout": "Log Out"
|
||||
@@ -412,6 +553,24 @@
|
||||
"navigation": {
|
||||
"dashboard": "Dashboard"
|
||||
},
|
||||
"notifications": {
|
||||
"permissionGranted": "Download notifications enabled",
|
||||
"permissionDenied": "Download notifications disabled",
|
||||
"downloadComplete": {
|
||||
"title": "Download Complete",
|
||||
"body": "{fileName} has finished downloading"
|
||||
},
|
||||
"downloadFailed": {
|
||||
"title": "Download Failed",
|
||||
"body": "Failed to download {fileName}: {error}",
|
||||
"unknownError": "Unknown error"
|
||||
},
|
||||
"queueProcessing": {
|
||||
"title": "Download Starting",
|
||||
"body": "{fileName} is now downloading{position}",
|
||||
"position": " (was #{position} in queue)"
|
||||
}
|
||||
},
|
||||
"profile": {
|
||||
"password": {
|
||||
"title": "Change Password",
|
||||
@@ -749,6 +908,7 @@
|
||||
"noFiles": "No files received yet",
|
||||
"noFilesDescription": "Files sent through this link will appear here",
|
||||
"fileCount": "{count, plural, =0 {No files} =1 {1 file} other {# files}}",
|
||||
"invalidDate": "Invalid date",
|
||||
"totalSize": "Total size: {size}",
|
||||
"columns": {
|
||||
"file": "File",
|
||||
@@ -900,7 +1060,8 @@
|
||||
"upload": {
|
||||
"metadata": {
|
||||
"title": "Send Files - Palmr",
|
||||
"description": "Send files through the shared link"
|
||||
"description": "Send files through the shared link",
|
||||
"descriptionWithLimit": "Upload files (max {limit} files)"
|
||||
},
|
||||
"layout": {
|
||||
"defaultTitle": "Send Files",
|
||||
@@ -1006,8 +1167,11 @@
|
||||
}
|
||||
},
|
||||
"searchBar": {
|
||||
"placeholder": "Search files...",
|
||||
"results": "Found {filtered} of {total} files"
|
||||
"placeholder": "Search files and folders...",
|
||||
"placeholderFiles": "Search files...",
|
||||
"placeholderFolders": "Search folders...",
|
||||
"results": "Showing {filtered} of {total} items",
|
||||
"noResults": "No results found for \"{query}\""
|
||||
},
|
||||
"settings": {
|
||||
"groups": {
|
||||
@@ -1051,6 +1215,10 @@
|
||||
"title": "Show Home Page",
|
||||
"description": "Show Home Page after installation"
|
||||
},
|
||||
"hideVersion": {
|
||||
"title": "Hide Version",
|
||||
"description": "Hide the Palmr version from the footer on all pages"
|
||||
},
|
||||
"smtpEnabled": {
|
||||
"title": "SMTP Enabled",
|
||||
"description": "Enable or disable SMTP email functionality"
|
||||
@@ -1197,22 +1365,27 @@
|
||||
"title": "Share Not Found",
|
||||
"description": "This share may have been deleted or expired."
|
||||
},
|
||||
"pageTitle": "Share"
|
||||
"pageTitle": "Share",
|
||||
"metadata": {
|
||||
"defaultDescription": "Share files securely",
|
||||
"filesShared": "{count, plural, =1 {1 file shared} other {# files shared}}"
|
||||
}
|
||||
},
|
||||
"shareActions": {
|
||||
"fileTitle": "Share File",
|
||||
"folderTitle": "Share Folder",
|
||||
"linkTitle": "Generate Link",
|
||||
"linkDescriptionFile": "Generate a custom link to share the file",
|
||||
"linkDescriptionFolder": "Generate a custom link to share the folder",
|
||||
"aliasLabel": "Link Alias",
|
||||
"aliasPlaceholder": "Enter custom alias",
|
||||
"linkReady": "Your share link is ready:",
|
||||
"generateLink": "Generate Link",
|
||||
"copyLink": "Copy Link",
|
||||
"deleteTitle": "Delete Share",
|
||||
"deleteConfirmation": "Are you sure you want to delete this share? This action cannot be undone.",
|
||||
"addDescriptionPlaceholder": "Add description...",
|
||||
"editTitle": "Edit Share",
|
||||
"nameLabel": "Share Name",
|
||||
"descriptionLabel": "Description",
|
||||
"descriptionPlaceholder": "Enter a description (optional)",
|
||||
"expirationLabel": "Expiration Date",
|
||||
"expirationPlaceholder": "MM/DD/YYYY HH:MM",
|
||||
"maxViewsLabel": "Max Views",
|
||||
"maxViewsPlaceholder": "Leave empty for unlimited",
|
||||
"passwordProtection": "Password Protected",
|
||||
"passwordLabel": "Password",
|
||||
"passwordPlaceholder": "Enter password",
|
||||
"newPasswordLabel": "New Password (leave empty to keep current)",
|
||||
"newPasswordPlaceholder": "Enter new password",
|
||||
"manageFilesTitle": "Manage Files",
|
||||
@@ -1283,28 +1456,6 @@
|
||||
"noExpiration": "This share will never expire and will remain accessible indefinitely."
|
||||
}
|
||||
},
|
||||
"shareFile": {
|
||||
"title": "Share File",
|
||||
"linkTitle": "Generate Link",
|
||||
"nameLabel": "Share Name",
|
||||
"namePlaceholder": "Enter share name",
|
||||
"descriptionLabel": "Description",
|
||||
"descriptionPlaceholder": "Enter a description (optional)",
|
||||
"expirationLabel": "Expiration Date",
|
||||
"expirationPlaceholder": "MM/DD/YYYY HH:MM",
|
||||
"maxViewsLabel": "Maximum Views",
|
||||
"maxViewsPlaceholder": "Leave empty for unlimited",
|
||||
"passwordProtection": "Password Protected",
|
||||
"passwordLabel": "Password",
|
||||
"passwordPlaceholder": "Enter password",
|
||||
"linkDescription": "Generate a custom link to share the file",
|
||||
"aliasLabel": "Link Alias",
|
||||
"aliasPlaceholder": "Enter custom alias",
|
||||
"linkReady": "Your share link is ready:",
|
||||
"createShare": "Create Share",
|
||||
"generateLink": "Generate Link",
|
||||
"copyLink": "Copy Link"
|
||||
},
|
||||
"shareManager": {
|
||||
"deleteSuccess": "Share deleted successfully",
|
||||
"deleteError": "Failed to delete share",
|
||||
@@ -1342,11 +1493,12 @@
|
||||
"shareNamePlaceholder": "Enter share name",
|
||||
"descriptionLabel": "Description",
|
||||
"descriptionPlaceholder": "Enter a description (optional)",
|
||||
"filesToShare": "Files to share",
|
||||
"filesToShare": "Files to Share",
|
||||
"files": "files",
|
||||
"totalSize": "Total size",
|
||||
"creating": "Creating...",
|
||||
"create": "Create Share"
|
||||
"creating": "Creating share...",
|
||||
"create": "Create Share",
|
||||
"itemsToShare": "Items to share ({count} {count, plural, =1 {item} other {items}})"
|
||||
},
|
||||
"shareSecurity": {
|
||||
"title": "Share Security Settings",
|
||||
@@ -1429,6 +1581,7 @@
|
||||
"public": "Public"
|
||||
},
|
||||
"filesCount": "files",
|
||||
"folderCount": "folders",
|
||||
"recipientsCount": "recipients",
|
||||
"actions": {
|
||||
"menu": "Share actions menu",
|
||||
@@ -1634,6 +1787,7 @@
|
||||
"selectFile": "Click to select a file",
|
||||
"selectMultipleFiles": "Click to select one or multiple files",
|
||||
"dragAndDrop": "or drag and drop files here",
|
||||
"filesQueued": "{count, plural, one {# file queued for upload} other {# files queued for upload}}",
|
||||
"preview": "Preview",
|
||||
"uploadProgress": "Upload progress",
|
||||
"upload": "Upload",
|
||||
@@ -1730,6 +1884,18 @@
|
||||
"userr": "User"
|
||||
}
|
||||
},
|
||||
"embedCode": {
|
||||
"title": "Embed Image",
|
||||
"description": "Use these codes to embed this image in forums, websites, or other platforms",
|
||||
"tabs": {
|
||||
"directLink": "Direct Link",
|
||||
"html": "HTML",
|
||||
"bbcode": "BBCode"
|
||||
},
|
||||
"directLinkDescription": "Direct URL to the image file",
|
||||
"htmlDescription": "Use this code to embed the image in HTML pages",
|
||||
"bbcodeDescription": "Use this code to embed the image in forums that support BBCode"
|
||||
},
|
||||
"validation": {
|
||||
"firstNameRequired": "First name is required",
|
||||
"lastNameRequired": "Last name is required",
|
||||
|
@@ -144,7 +144,15 @@
|
||||
"update": "Actualizar",
|
||||
"click": "Haga clic para",
|
||||
"creating": "Creando...",
|
||||
"loadingSimple": "Cargando..."
|
||||
"loadingSimple": "Cargando...",
|
||||
"create": "Crear",
|
||||
"deleting": "Eliminando...",
|
||||
"move": "Mover",
|
||||
"rename": "Renombrar",
|
||||
"search": "Buscar",
|
||||
"share": "Compartir",
|
||||
"copied": "Copiado",
|
||||
"copy": "Copiar"
|
||||
},
|
||||
"createShare": {
|
||||
"title": "Crear Compartir",
|
||||
@@ -159,7 +167,54 @@
|
||||
"passwordLabel": "Contraseña",
|
||||
"create": "Crear Compartir",
|
||||
"success": "Compartir creado exitosamente",
|
||||
"error": "Error al crear compartir"
|
||||
"error": "Error al crear compartir",
|
||||
"namePlaceholder": "Ingrese un nombre para su compartir",
|
||||
"nextSelectFiles": "Siguiente: Seleccionar archivos",
|
||||
"searchLabel": "Buscar",
|
||||
"tabs": {
|
||||
"shareDetails": "Detalles del compartido",
|
||||
"selectFiles": "Seleccionar archivos"
|
||||
}
|
||||
},
|
||||
"customization": {
|
||||
"breadcrumb": "Personalización",
|
||||
"colors": {
|
||||
"title": "Colores del Tema",
|
||||
"description": "Elige tu color primario preferido para el tema",
|
||||
"presets": "Colores Disponibles",
|
||||
"presetsDescription": "Selecciona entre los temas de colores disponibles",
|
||||
"reset": "Restablecer por Defecto"
|
||||
},
|
||||
"fonts": {
|
||||
"title": "Tipografía",
|
||||
"description": "Elige tu familia de fuentes preferida",
|
||||
"available": "Fuentes Disponibles",
|
||||
"availableDescription": "Selecciona entre las familias de fuentes disponibles",
|
||||
"reset": "Restablecer por Defecto"
|
||||
},
|
||||
"radius": {
|
||||
"title": "Radio del Borde",
|
||||
"description": "Personaliza la redondez de los elementos de la interfaz",
|
||||
"available": "Opciones de Redondez",
|
||||
"availableDescription": "Elige cómo deben aparecer las esquinas redondeadas",
|
||||
"reset": "Restablecer por Defecto"
|
||||
},
|
||||
"background": {
|
||||
"title": "Colores de Fondo",
|
||||
"description": "Personaliza los colores de fondo para los modos claro y oscuro",
|
||||
"lightMode": "Modo Claro",
|
||||
"darkMode": "Modo Oscuro",
|
||||
"availableDescription": "Elige los colores de fondo para los temas claro y oscuro",
|
||||
"reset": "Restablecer por Defecto"
|
||||
},
|
||||
"theme": {
|
||||
"title": "Modo del Tema",
|
||||
"description": "Elige entre tema claro, oscuro o del sistema",
|
||||
"selectTheme": "Preferencia de Tema",
|
||||
"availableDescription": "Selecciona tu modo de tema preferido",
|
||||
"reset": "Restablecer al Sistema"
|
||||
},
|
||||
"pageTitle": "Personalización"
|
||||
},
|
||||
"dashboard": {
|
||||
"loadError": "Error al cargar los datos del tablero",
|
||||
@@ -173,7 +228,42 @@
|
||||
},
|
||||
"deleteConfirmation": {
|
||||
"filesToDelete": "Archivos que serán eliminados",
|
||||
"sharesToDelete": "Compartidos que serán eliminados"
|
||||
"sharesToDelete": "Compartidos que serán eliminados",
|
||||
"foldersToDelete": "Carpetas a eliminar",
|
||||
"itemsToDelete": "Elementos a eliminar"
|
||||
},
|
||||
"downloadQueue": {
|
||||
"downloadQueued": "Descarga en cola: {fileName}",
|
||||
"queuedDescription": "Tu descarga comenzará automáticamente cuando haya un espacio disponible",
|
||||
"queuePosition": "Descarga en cola en posición {position}: {fileName}",
|
||||
"estimatedWait": "Tiempo estimado de espera: {time}",
|
||||
"queueFull": "Cola de descarga llena",
|
||||
"queueFullDescription": "Por favor, inténtalo de nuevo en unos minutos cuando la cola tenga espacio",
|
||||
"cancelSuccess": "Descarga cancelada exitosamente",
|
||||
"cancelError": "Error al cancelar la descarga: {error}",
|
||||
"status": {
|
||||
"pending": "Preparando...",
|
||||
"queued": "En cola",
|
||||
"downloading": "Descargando",
|
||||
"completed": "Completado",
|
||||
"failed": "Fallido"
|
||||
},
|
||||
"waitTime": {
|
||||
"seconds": "{seconds}s",
|
||||
"minutes": "{minutes}m",
|
||||
"hoursMinutes": "{hours}h {minutes}m"
|
||||
},
|
||||
"indicator": {
|
||||
"title": "Descargas",
|
||||
"downloads": "Cola de Descargas",
|
||||
"active": "Activas",
|
||||
"queued": "En Cola",
|
||||
"position": "Posición {position}",
|
||||
"estimatedWait": "Espera: {time}",
|
||||
"unknownFile": "Archivo desconocido",
|
||||
"noDownloads": "No hay descargas en progreso",
|
||||
"refresh": "Actualizar Cola"
|
||||
}
|
||||
},
|
||||
"emptyState": {
|
||||
"noFiles": "Aún no se han subido archivos",
|
||||
@@ -200,6 +290,7 @@
|
||||
"extension": "Extensión",
|
||||
"descriptionLabel": "Descripción",
|
||||
"descriptionPlaceholder": "Introduce una descripción del archivo",
|
||||
"addDescriptionPlaceholder": "Agregar descripción...",
|
||||
"deleteFile": "Eliminar archivo",
|
||||
"deleteConfirmation": "¿Estás seguro de que deseas eliminar ?",
|
||||
"deleteWarning": "Esta acción no se puede deshacer."
|
||||
@@ -213,6 +304,7 @@
|
||||
},
|
||||
"filePreview": {
|
||||
"title": "Vista Previa del Archivo",
|
||||
"description": "Vista previa y descarga de archivo",
|
||||
"loading": "Cargando...",
|
||||
"notAvailable": "Vista previa no disponible para este tipo de archivo.",
|
||||
"downloadToView": "Use el botón de descarga para descargar el archivo.",
|
||||
@@ -247,7 +339,8 @@
|
||||
"previewFile": "Vista previa del archivo",
|
||||
"addToShare": "Agregar a compartición",
|
||||
"removeFromShare": "Quitar de compartición",
|
||||
"saveChanges": "Guardar Cambios"
|
||||
"saveChanges": "Guardar Cambios",
|
||||
"editFolder": "Editar carpeta"
|
||||
},
|
||||
"files": {
|
||||
"title": "Todos los Archivos",
|
||||
@@ -266,11 +359,24 @@
|
||||
"bulkDownloadFileError": "Error al descargar archivo {fileName}",
|
||||
"bulkDeleteSuccess": "{count, plural, =1 {1 archivo eliminado exitosamente} other {# archivos eliminados exitosamente}}",
|
||||
"bulkDeleteError": "Error al eliminar archivos seleccionados",
|
||||
"bulkDeleteTitle": "Eliminar Archivos Seleccionados",
|
||||
"bulkDeleteConfirmation": "¿Está seguro de que desea eliminar {count, plural, =1 {1 archivo} other {# archivos}}? Esta acción no se puede deshacer.",
|
||||
"viewMode": {
|
||||
"table": "Tabla",
|
||||
"grid": "Cuadrícula"
|
||||
},
|
||||
"totalFiles": "{count, plural, =0 {Sin archivos} =1 {1 archivo} other {# archivos}}"
|
||||
"totalFiles": "{count, plural, =0 {Sin archivos} =1 {1 archivo} other {# archivos}}",
|
||||
"actions": {
|
||||
"open": "Abrir",
|
||||
"rename": "Renombrar",
|
||||
"delete": "Eliminar"
|
||||
},
|
||||
"empty": {
|
||||
"title": "Aún no hay archivos o carpetas",
|
||||
"description": "Suba su primer archivo o cree una carpeta para comenzar"
|
||||
},
|
||||
"files": "archivos",
|
||||
"folders": "carpetas"
|
||||
},
|
||||
"filesTable": {
|
||||
"ariaLabel": "Tabla de archivos",
|
||||
@@ -300,6 +406,33 @@
|
||||
"delete": "Eliminar Seleccionados"
|
||||
}
|
||||
},
|
||||
"folderActions": {
|
||||
"editFolder": "Editar carpeta",
|
||||
"folderName": "Nombre de carpeta",
|
||||
"folderNamePlaceholder": "Ingrese nombre de carpeta",
|
||||
"folderDescription": "Descripción",
|
||||
"folderDescriptionPlaceholder": "Ingrese descripción de carpeta (opcional)",
|
||||
"createFolder": "Crear nueva carpeta",
|
||||
"renameFolder": "Renombrar carpeta",
|
||||
"moveFolder": "Mover carpeta",
|
||||
"shareFolder": "Compartir carpeta",
|
||||
"deleteFolder": "Eliminar carpeta",
|
||||
"moveTo": "Mover a",
|
||||
"selectDestination": "Seleccionar carpeta destino",
|
||||
"rootFolder": "Raíz",
|
||||
"folderCreated": "Carpeta creada exitosamente",
|
||||
"folderRenamed": "Carpeta renombrada exitosamente",
|
||||
"folderMoved": "Carpeta movida exitosamente",
|
||||
"folderDeleted": "Carpeta eliminada exitosamente",
|
||||
"folderShared": "Carpeta compartida exitosamente",
|
||||
"createFolderError": "Error al crear carpeta",
|
||||
"renameFolderError": "Error al renombrar carpeta",
|
||||
"moveFolderError": "Error al mover carpeta",
|
||||
"deleteFolderError": "Error al eliminar carpeta",
|
||||
"shareFolderError": "Error al compartir carpeta",
|
||||
"deleteConfirmation": "¿Está seguro de que desea eliminar esta carpeta?",
|
||||
"deleteWarning": "Esta acción no se puede deshacer."
|
||||
},
|
||||
"footer": {
|
||||
"poweredBy": "Desarrollado por",
|
||||
"kyanHomepage": "Página principal de Kyantech"
|
||||
@@ -401,17 +534,43 @@
|
||||
"removeFailed": "Error al eliminar el logo"
|
||||
}
|
||||
},
|
||||
"moveItems": {
|
||||
"itemsToMove": "Elementos a mover:",
|
||||
"movingTo": "Moviendo a:",
|
||||
"title": "Mover {count, plural, =1 {elemento} other {elementos}}",
|
||||
"description": "Mover {count, plural, =1 {elemento} other {elementos}} a una nueva ubicación",
|
||||
"success": "Se movieron exitosamente {count} {count, plural, =1 {elemento} other {elementos}}"
|
||||
},
|
||||
"navbar": {
|
||||
"logoAlt": "Logo de la aplicación",
|
||||
"profileMenu": "Menú de perfil",
|
||||
"profile": "Perfil",
|
||||
"settings": "Configuración",
|
||||
"usersManagement": "Gestión de usuarios",
|
||||
"logout": "Cerrar sesión"
|
||||
"logout": "Cerrar sesión",
|
||||
"customization": "Personalización"
|
||||
},
|
||||
"navigation": {
|
||||
"dashboard": "Panel de control"
|
||||
},
|
||||
"notifications": {
|
||||
"permissionGranted": "Notificaciones de descarga habilitadas",
|
||||
"permissionDenied": "Notificaciones de descarga deshabilitadas",
|
||||
"downloadComplete": {
|
||||
"title": "Descarga Completada",
|
||||
"body": "{fileName} ha terminado de descargarse"
|
||||
},
|
||||
"downloadFailed": {
|
||||
"title": "Descarga Fallida",
|
||||
"body": "Error al descargar {fileName}: {error}",
|
||||
"unknownError": "Error desconocido"
|
||||
},
|
||||
"queueProcessing": {
|
||||
"title": "Descarga Iniciando",
|
||||
"body": "{fileName} está descargándose ahora{position}",
|
||||
"position": " (estaba en posición #{position} en la cola)"
|
||||
}
|
||||
},
|
||||
"profile": {
|
||||
"password": {
|
||||
"title": "Cambiar contraseña",
|
||||
@@ -454,6 +613,11 @@
|
||||
},
|
||||
"pageTitle": "Perfil"
|
||||
},
|
||||
"qrCodeModal": {
|
||||
"title": "Compartir Código QR",
|
||||
"description": "Escanea este código QR para acceder al enlace.",
|
||||
"download": "Descargar Código QR"
|
||||
},
|
||||
"quickAccess": {
|
||||
"files": {
|
||||
"title": "Mis archivos",
|
||||
@@ -744,6 +908,7 @@
|
||||
"noFiles": "Ningún archivo recibido aún",
|
||||
"noFilesDescription": "Los archivos enviados a través de este enlace aparecerán aquí",
|
||||
"fileCount": "{count, plural, =0 {Ningún archivo} =1 {1 archivo} other {# archivos}}",
|
||||
"invalidDate": "Fecha inválida",
|
||||
"totalSize": "Tamaño total: {size}",
|
||||
"columns": {
|
||||
"file": "Archivo",
|
||||
@@ -894,7 +1059,8 @@
|
||||
"upload": {
|
||||
"metadata": {
|
||||
"title": "Enviar Archivos - Palmr",
|
||||
"description": "Envía archivos a través del enlace compartido"
|
||||
"description": "Envía archivos a través del enlace compartido",
|
||||
"descriptionWithLimit": "Subir archivos (máx. {limit} archivos)"
|
||||
},
|
||||
"layout": {
|
||||
"defaultTitle": "Enviar Archivos",
|
||||
@@ -1004,7 +1170,10 @@
|
||||
},
|
||||
"searchBar": {
|
||||
"placeholder": "Buscar archivos...",
|
||||
"results": "Se encontraron {filtered} de {total} archivos"
|
||||
"results": "Se encontraron {filtered} de {total} archivos",
|
||||
"placeholderFolders": "Buscar carpetas...",
|
||||
"noResults": "No se encontraron resultados para \"{query}\"",
|
||||
"placeholderFiles": "Buscar archivos..."
|
||||
},
|
||||
"settings": {
|
||||
"groups": {
|
||||
@@ -1133,6 +1302,10 @@
|
||||
"passwordAuthEnabled": {
|
||||
"title": "Autenticación por Contraseña",
|
||||
"description": "Habilitar o deshabilitar la autenticación basada en contraseña"
|
||||
},
|
||||
"hideVersion": {
|
||||
"title": "Ocultar Versión",
|
||||
"description": "Ocultar la versión de Palmr en el pie de página de todas las páginas"
|
||||
}
|
||||
},
|
||||
"buttons": {
|
||||
@@ -1194,11 +1367,16 @@
|
||||
"description": "Esta compartición puede haber sido eliminada o haber expirado."
|
||||
},
|
||||
"pageTitle": "Compartición",
|
||||
"downloadAll": "Descargar Todo"
|
||||
"downloadAll": "Descargar Todo",
|
||||
"metadata": {
|
||||
"defaultDescription": "Compartir archivos de forma segura",
|
||||
"filesShared": "{count, plural, =1 {1 archivo compartido} other {# archivos compartidos}}"
|
||||
}
|
||||
},
|
||||
"shareActions": {
|
||||
"deleteTitle": "Eliminar Compartir",
|
||||
"deleteConfirmation": "¿Estás seguro de que deseas eliminar esta compartición? Esta acción no se puede deshacer.",
|
||||
"addDescriptionPlaceholder": "Agregar descripción...",
|
||||
"editTitle": "Editar Compartir",
|
||||
"nameLabel": "Nombre del Compartir",
|
||||
"descriptionLabel": "Descripción",
|
||||
@@ -1217,7 +1395,17 @@
|
||||
"editSuccess": "Compartir actualizado exitosamente",
|
||||
"editError": "Error al actualizar compartir",
|
||||
"bulkDeleteConfirmation": "¿Estás seguro de que quieres eliminar {count, plural, =1 {1 compartido} other {# compartidos}}? Esta acción no se puede deshacer.",
|
||||
"bulkDeleteTitle": "Eliminar Compartidos Seleccionados"
|
||||
"bulkDeleteTitle": "Eliminar Compartidos Seleccionados",
|
||||
"aliasLabel": "Alias del enlace",
|
||||
"aliasPlaceholder": "Ingrese alias personalizado",
|
||||
"copyLink": "Copiar enlace",
|
||||
"fileTitle": "Compartir archivo",
|
||||
"folderTitle": "Compartir carpeta",
|
||||
"generateLink": "Generar enlace",
|
||||
"linkDescriptionFile": "Genere un enlace personalizado para compartir el archivo",
|
||||
"linkDescriptionFolder": "Genere un enlace personalizado para compartir la carpeta",
|
||||
"linkReady": "Su enlace de compartición está listo:",
|
||||
"linkTitle": "Generar enlace"
|
||||
},
|
||||
"shareDetails": {
|
||||
"title": "Detalles del Compartir",
|
||||
@@ -1344,7 +1532,8 @@
|
||||
"files": "archivos",
|
||||
"totalSize": "Tamaño total",
|
||||
"creating": "Creando...",
|
||||
"create": "Crear Compartir"
|
||||
"create": "Crear Compartir",
|
||||
"itemsToShare": "Elementos a compartir ({count} {count, plural, =1 {elemento} other {elementos}})"
|
||||
},
|
||||
"shareSecurity": {
|
||||
"subtitle": "Configurar protección por contraseña y opciones de seguridad para este compartir",
|
||||
@@ -1427,6 +1616,7 @@
|
||||
"public": "Público"
|
||||
},
|
||||
"filesCount": "archivos",
|
||||
"folderCount": "carpetas",
|
||||
"recipientsCount": "destinatarios",
|
||||
"actions": {
|
||||
"menu": "Menú de acciones de compartir",
|
||||
@@ -1657,7 +1847,8 @@
|
||||
"title": "Suelta archivos para subir",
|
||||
"description": "Suelta para subir tus archivos"
|
||||
},
|
||||
"pasteSuccess": "{count, plural, =1 {Imagen pegada y subida exitosamente} other {# imágenes pegadas y subidas exitosamente}}"
|
||||
"pasteSuccess": "{count, plural, =1 {Imagen pegada y subida exitosamente} other {# imágenes pegadas y subidas exitosamente}}",
|
||||
"filesQueued": "{count, plural, one {# archivo en cola para subir} other {# archivos en cola para subir}}"
|
||||
},
|
||||
"users": {
|
||||
"modes": {
|
||||
@@ -1743,9 +1934,16 @@
|
||||
"nameRequired": "El nombre es obligatorio",
|
||||
"required": "Este campo es obligatorio"
|
||||
},
|
||||
"qrCodeModal": {
|
||||
"title": "Compartir Código QR",
|
||||
"description": "Escanea este código QR para acceder al enlace.",
|
||||
"download": "Descargar Código QR"
|
||||
"embedCode": {
|
||||
"title": "Insertar imagen",
|
||||
"description": "Utiliza estos códigos para insertar esta imagen en foros, sitios web u otras plataformas",
|
||||
"tabs": {
|
||||
"directLink": "Enlace directo",
|
||||
"html": "HTML",
|
||||
"bbcode": "BBCode"
|
||||
},
|
||||
"directLinkDescription": "URL directa al archivo de imagen",
|
||||
"htmlDescription": "Utiliza este código para insertar la imagen en páginas HTML",
|
||||
"bbcodeDescription": "Utiliza este código para insertar la imagen en foros que admiten BBCode"
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user