-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(media): create the official media plugin
- Create the @tensei/media plugin - Setup graphql file upload mutation for media plugin - Handle multiple file uploads - Save uploaded files to storage
- Loading branch information
Frantz Kati
committed
Dec 1, 2020
1 parent
f3c00af
commit e373a87
Showing
42 changed files
with
747 additions
and
807 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Axios upload</title> | ||
</head> | ||
<body> | ||
<form action="" onsubmit="on_form_upload(event)"> | ||
<input type="file" name="files" id="files" multiple> | ||
|
||
<button type='submit'>Submit</button> | ||
</form> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.21.0/axios.min.js" integrity="sha512-DZqqY3PiOvTP9HkjIWgjO6ouCbq+dxqWoJZ/Q+zPYNHmlnI2dQnbJ5bxAHpAMw+LXRm4D72EIRXzvcHQtE8/VQ==" crossorigin="anonymous"></script> | ||
<script> | ||
function on_form_upload(event) { | ||
event.preventDefault() | ||
|
||
const files = document.getElementById('files').files | ||
console.log(files) | ||
} | ||
</script> | ||
</body> | ||
</html> |
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,17 @@ | ||
- Create a `Media` resource | ||
- Add the following fields to the resource: | ||
- Unique UUID | ||
- Parent ID, to mark this media as owned by another media. This will allow a single media to have multiple conversions / transformations | ||
- File Size, to save the file size in KB | ||
- File Name, to save the original name of the file | ||
- Model ID, to save the related model id to this file | ||
- Alt Text, nullable, to save the alt text for this file, used only for image media types | ||
- Caption, nullable, to caption an image. | ||
- Ext, to save the file extension | ||
- Mime, to save the file mime type | ||
- Provider, to save the file upload provider | ||
- Provider Meta, to save metadata for the media upload provider, for example, saving the media ID from cloudinary or dropbox | ||
|
||
- Associate the Media resource with different resources in the app. | ||
- User `hasOne('Media')`, and the hasOne foreign key field is Model ID, and the relation name is `avatar` | ||
- Post `hasMany('Media')`, and the hasMany foreign key field is Model ID, and the relation name is `sliders` |
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.