Skip to content

Commit

Permalink
ci/cd: using minio to test s3
Browse files Browse the repository at this point in the history
  • Loading branch information
HendrixString committed Jan 14, 2025
1 parent 411f7d2 commit c3ae7c2
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 15 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

[![Core](https://github.com/store-craft/storecraft/actions/workflows/test.core.yml/badge.svg)](https://github.com/store-craft/storecraft/actions/workflows/test.core.yml)
[![MongoDB](https://github.com/store-craft/storecraft/actions/workflows/test.database-mongodb.yml/badge.svg)](https://github.com/store-craft/storecraft/actions/workflows/test.database-mongodb.yml)[![SQLite / Postgres / MySQL](https://github.com/store-craft/storecraft/actions/workflows/test.database-sql.yml/badge.svg)](https://github.com/store-craft/storecraft/actions/workflows/test.database-sql.yml)
[![S3 Compatible](https://github.com/store-craft/storecraft/actions/workflows/test.storage-s3-compatible.yml/badge.svg)](https://github.com/store-craft/storecraft/actions/workflows/test.storage-s3-compatible.yml)


# The <img src='https://storecraft.app/storecraft-color.svg' height='24px' style="transform: translateY(4px);" /> mono-repo

Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion packages/core/rest/con.storage.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ export const create_routes = (app) => {
res.sendJson(r);
} else {

await app.storage.putStream(file_key, req.body);
await app.storage.putStream(
file_key, req.body, {},
parseInt(req.headers.get("Content-Length") ?? '0')
);

res.headers.set(HEADER_PRESIGNED, 'false');
res.end();
Expand Down
2 changes: 1 addition & 1 deletion packages/core/storage/types.storage.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export declare interface storage_driver {
*/
putBlob: (key: string, blob: Blob, meta?: MetaData) => Promise<boolean>;
putArraybuffer: (key: string, buffer: ArrayBuffer, meta?: MetaData) => Promise<boolean>;
putStream: (key: string, stream: Partial<ReadableStream<any>>, meta?: MetaData) => Promise<boolean>;
putStream: (key: string, stream: Partial<ReadableStream<any>>, meta?: MetaData, bytesLength: number) => Promise<boolean>;
putSigned?: (key: string) => Promise<StorageSignedOperation | undefined>;

/**
Expand Down
5 changes: 1 addition & 4 deletions packages/core/test-runner/storage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,7 @@ export const create = (storage, name) => {
for (const d of data) {
// @ts-ignore
const success = await storage.putStream(
d.key, d.stream,
{
'Content-Length': d.length
}
d.key, d.stream, {}, d.buffer.byteLength
);
// read
const get_stream = await storage.getStream(d.key);
Expand Down
2 changes: 2 additions & 0 deletions packages/storage/storage-s3-compatible/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
width='90%' />
</div><hr/><br/>

[![S3 Compatible](https://github.com/store-craft/storecraft/actions/workflows/test.storage-s3-compatible.yml/badge.svg)](https://github.com/store-craft/storecraft/actions/workflows/test.storage-s3-compatible.yml)

`fetch` ready support for an `S3` like storage:
- `Amazon S3`
- `Cloudflare R2`
Expand Down
11 changes: 8 additions & 3 deletions packages/storage/storage-s3-compatible/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,15 @@ export class S3CompatibleStorage {
*
* @type {storage["putStream"]}
*/
async putStream(key, stream, meta) {
// @ts-ignore
async putStream(key, stream, meta={}, bytesLength=0) {
const extra_headers = {};
if(Boolean(bytesLength)) {
extra_headers["Content-Length"] = bytesLength;
}

return this.#put_internal(
key, stream, meta
// @ts-ignore
key, stream, extra_headers
);
}

Expand Down
5 changes: 3 additions & 2 deletions packages/storage/storage-s3-compatible/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@storecraft/storage-s3-compatible",
"version": "1.0.7",
"version": "1.0.8",
"description": "Official S3-Compatible Storage adapter for storecraft",
"license": "MIT",
"author": "Tomer Shalev (https://github.com/store-craft)",
Expand All @@ -18,7 +18,8 @@
],
"scripts": {
"test": "node ./tests/storage.s3-compatible.test.js",
"prepublishOnly": "npm version patch --force"
"prepublishOnly": "npm version patch --force",
"sc-publish": "npm publish"
},
"type": "module",
"main": "adapter.js",
Expand Down

0 comments on commit c3ae7c2

Please sign in to comment.