Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/add-remote-file-upload-api #9906

Merged
merged 20 commits into from
Nov 1, 2024
Merged

Conversation

laipz8200
Copy link
Member

@laipz8200 laipz8200 commented Oct 26, 2024

Checklist:

Important

Please review the checklist below before submitting your pull request.

  • Please open an issue before creating a PR or link to an existing issue In udify.app, can't display external images because of CSP #9878
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

Description

  1. File Upload Refactoring:

    • Refactored file upload logic in multiple controllers to use a new FileService.upload_file method signature.
    • The new method takes separate parameters for filename, content, mimetype, user, and source instead of a FileStorage object.
    • Added checks for empty filenames and improved error handling.
  2. Remote File Handling:

    • Implemented a RemoteFileUploadApi class for handling remote file operations.
    • Added functionality to download remote files, guess MIME types and generate filenames when needed.
  3. Error Handling:

    • Introduced a new FilenameNotExistsError for cases where a file is uploaded without a filename.
  4. Controller Restructuring:

    • Moved file-related controllers from web/__init__.py to separate web/files.py and web/remote_files.py files.
    • Updated imports and API resource registrations accordingly.
  5. Setup Required Decorator:

    • Moved the setup_required decorator from setup.py to wraps.py.
    • Updated all imports of setup_required to use the new location.

Fixes

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update, included: Dify Document
  • Improvement, including but not limited to code refactoring, performance optimization, and UI/UX improvement
  • Dependency upgrade

Testing Instructions

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A
  • Test B

- Add `source_url` field to `UploadFile` model to store source URLs.
- Update database schema to include `source_url` column with a server default of an empty string.
- Modify constructors and methods to handle `source_url` parameter.
- Enhance file upload APIs to capture source URLs.
@laipz8200 laipz8200 force-pushed the feat/add-remote-file-upload-api branch from 7d2baf1 to 8366683 Compare November 1, 2024 07:45
@laipz8200 laipz8200 marked this pull request as ready for review November 1, 2024 07:45
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Nov 1, 2024
@laipz8200 laipz8200 requested a review from zxhlyh November 1, 2024 07:45
@dosubot dosubot bot added the 💪 enhancement New feature or request label Nov 1, 2024
@laipz8200 laipz8200 requested a review from crazywoola November 1, 2024 07:50
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Nov 1, 2024
@laipz8200 laipz8200 merged commit 9ac2bb3 into main Nov 1, 2024
10 checks passed
@laipz8200 laipz8200 deleted the feat/add-remote-file-upload-api branch November 1, 2024 07:51
AlwaysBluer pushed a commit to AlwaysBluer/dify that referenced this pull request Nov 2, 2024
…m-vdb

* 'lindorm-vdb' of github.com:AlwaysBluer/dify: (39 commits)
  Feat : add LLM model indicator in prompt generator (langgenius#10187)
  chore: enable vision support for models in OpenRouter that should have supported vision (langgenius#10191)
  chore : code generator preview hint (langgenius#10188)
  fix: webapp upload file (langgenius#10195)
  fix(api): replace current_user with end_user in file upload (langgenius#10194)
  feat(document_extractor): integrate unstructured API for PPTX extraction (langgenius#10180)
  fix(tools): suppress RuntimeWarnings in podcast audio generator (langgenius#10182)
  [fix] fix the bug that modify document name not effective (langgenius#10154)
  fix(workflow model): ensure consistent timestamp updating (langgenius#10172)
  fix: Cannot find declaration to go to CLEAN_DAY_SETTING (langgenius#10157)
  feat: add gpustack model provider (langgenius#10158)
  refactor(tools): Avoid warnings. (langgenius#10161)
  refactor(migration/model): update column types for workflow schema (langgenius#10160)
  Feat/add-remote-file-upload-api (langgenius#9906)
  fix: upload remote image preview (langgenius#9952)
  clean un-allowed special charters when doing indexing estimate (langgenius#10153)
  refactor(service): handle unsupported DSL version with warning (langgenius#10151)
  Add VESSL AI OpenAI API-compatible model provider and LLM model (langgenius#9474)
  feat: synchronize input/output variables in the panel with generated code by the code generator (langgenius#10150)
  Refined README for better reading experience. (langgenius#10143)
  ...
Nov1c444 pushed a commit that referenced this pull request Nov 5, 2024
iamjoel pushed a commit that referenced this pull request Nov 7, 2024
idonotknow pushed a commit to AceDataCloud/Dify that referenced this pull request Nov 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💪 enhancement New feature or request lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants