-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c790401
commit 0b84c98
Showing
13 changed files
with
7,336 additions
and
5,209 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,24 @@ | ||
import { PutObjectCommand } from '@aws-sdk/client-s3' | ||
import { sha256 } from 'multiformats/hashes/sha2' | ||
import { toString } from 'uint8arrays' | ||
|
||
/** | ||
* @param {Blob} content | ||
* @param {import('../env').Env} env | ||
*/ | ||
export async function backup (content, env) { | ||
if (!env.s3Client) { | ||
return undefined | ||
} | ||
|
||
const data = await content.arrayBuffer() | ||
const key = await sha256.digest(new Uint8Array(data)) | ||
const keyStr = toString(key.bytes, 'base32') | ||
const bucketParams = { | ||
Bucket: env.s3BucketName, | ||
Key: keyStr, | ||
Body: content | ||
} | ||
await env.s3Client.send(new PutObjectCommand(bucketParams)) | ||
return keyStr | ||
} |
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,9 @@ | ||
/** | ||
* https://github.com/sinedied/smoke#javascript-mocks | ||
*/ | ||
module.exports = () => { | ||
return { | ||
statusCode: 200, | ||
headers: { 'Content-Type': 'application/json' } | ||
} | ||
} |
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.