-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Why: - the deployment was attempting to store/fetch data locally which isn't a possibility in the current setup, implicating the need to setup cloud storage; How: - to address the issue a new payload-compatible storage adpater has been created to enable this build as a git-based CMS using [Octokit](https://octokit.github.io/rest.js/v21/) to manage files;
- Loading branch information
Showing
20 changed files
with
307 additions
and
30 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
Empty file.
Empty file.
Empty file.
Empty file.
Binary file not shown.
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
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
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,69 @@ | ||
import { GeneratedAdapter } from "@payloadcms/plugin-cloud-storage/types"; | ||
import { Octokit } from "@octokit/rest"; | ||
|
||
const octokit = new Octokit({ | ||
auth: process.env.GITHUB_TOKEN, | ||
}); | ||
|
||
const owner = process.env.GITHUB_REPO_OWNER; | ||
const repo = process.env.GITHUB_REPO; | ||
const comitter = { | ||
name: "payload admin dashboard", | ||
email: "[email protected]", | ||
}; | ||
|
||
|
||
export const testAdapt = ({ collection, prefix }): GeneratedAdapter => { | ||
return { | ||
name: "Test", | ||
handleUpload: async (args) => { | ||
// @ts-ignore | ||
const buffer = Buffer.from(args.file.buffer, "base64"); | ||
const base64Buffer = buffer.toString("base64"); | ||
await octokit.repos.createOrUpdateFileContents({ | ||
// @ts-ignore | ||
owner: owner, | ||
// @ts-ignore | ||
repo: repo, | ||
path: `public/media/${args.file.filename}`, | ||
message: "Uploaded a new file via Octokit", | ||
content: base64Buffer, | ||
committer: comitter, | ||
author: comitter, | ||
}); | ||
|
||
|
||
}, | ||
// @ts-ignore | ||
handleDelete: async (args) => { | ||
|
||
|
||
const { data: fileData } = await octokit.rest.repos.getContent({ | ||
// @ts-ignore | ||
owner: owner, | ||
// @ts-ignore | ||
repo: repo, | ||
path: `public/media/${args.filename}`, | ||
}); | ||
|
||
|
||
await octokit.rest.repos.deleteFile({ | ||
// @ts-ignore | ||
owner: owner, | ||
// @ts-ignore | ||
repo: repo, | ||
// @ts-ignore | ||
path: `public/media/${args.filename}`, | ||
// @ts-ignore | ||
message: `Deleted file via Octokit`, | ||
// @ts-ignore | ||
sha: fileData.sha, | ||
}); | ||
}, | ||
// @ts-ignore | ||
staticHandler: async (req) => { | ||
}, | ||
|
||
}; | ||
|
||
}; |
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.