-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow migrating attachments from other places (#2807)
#### What type of PR is this? /kind improvement /area core /milestone 2.0.0 #### What this PR does / why we need it: This PR provides an ability to migrate attachments from other places, like Halo 1.x or Wordpress. We could simply configure resource mappings to support attachments migration: ```yaml halo: attachment: resource-mappings: - pathPattern: /upload/** locations: - upload - migrate-from-1.x - pathPattern: /wp-content/uploads/** locations: - migrate-from-wp ``` Meanwhile, I refactored LocalAttachmentUploadHandler for managing attachments from migration in the future. #### Which issue(s) this PR fixes: Fixes #2585 #### Special notes for your reviewer: **Steps to test:** 1. Try to configure the resource mappings 2. Put some static resources into the corresponding location 3. Access it from Browser At last, please make sure the functionalities of attachment are ok as before. #### Does this PR introduce a user-facing change? ```release-note None ```
- Loading branch information
Showing
8 changed files
with
123 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/main/java/run/halo/app/infra/properties/AttachmentProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package run.halo.app.infra.properties; | ||
|
||
import java.util.LinkedList; | ||
import java.util.List; | ||
import lombok.Data; | ||
|
||
@Data | ||
public class AttachmentProperties { | ||
|
||
private List<ResourceMapping> resourceMappings = new LinkedList<>(); | ||
|
||
@Data | ||
public static class ResourceMapping { | ||
|
||
/** | ||
* Like: {@code /upload/**}. | ||
*/ | ||
private String pathPattern; | ||
|
||
/** | ||
* The location is a relative path to attachments folder in working directory. | ||
*/ | ||
private List<String> locations; | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters