-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(uploads): Reorganise, change uploads package to storage (#11411)
- Loading branch information
Showing
29 changed files
with
209 additions
and
164 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
- chore(uploads): Reorganise, change uploads package to storage (#11411) by @dac09 | ||
|
||
This PR does the following: | ||
|
||
- renames `@redwoodjs/uploads` -> `@redwoodjs/storage` | ||
- Renames `processors` -> `savers` | ||
|
||
They now look like this: | ||
|
||
```ts | ||
// reads much nicer ✅ | ||
const processedInput = await saveFiles.forProfile(input) | ||
|
||
// avatar is a File becomes a string | ||
// processedInput.avatar = | ||
// '/basePath/uploads/profile-avatar-01J6ACDPWAER8B1SAXPKQK5YA1.png' | ||
|
||
const profile = await db.profile.update({ | ||
data: processedInput, | ||
where: { id }, | ||
}) | ||
``` | ||
|
||
even though when you export it, it looks weird | ||
|
||
```ts | ||
// api/src/lib/uploads.ts | ||
const { saveFiles, storagePrismaExtension } = setupStorage({ | ||
//... | ||
}) | ||
|
||
export { saveFiles, storagePrismaExtension } | ||
``` | ||
|
||
The naming convention is: | ||
`for<Model>` - takes inputs in the shape of a Prisma data for that model but with Files instead of strings. The files get saved to storage, and a key/path is replaced in the value. | ||
|
||
`inList` - does the same, but only takes an array of File, and returns an array of stored paths/keys |
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
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
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
Oops, something went wrong.