File tree Expand file tree Collapse file tree 7 files changed +64
-3
lines changed Expand file tree Collapse file tree 7 files changed +64
-3
lines changed Original file line number Diff line number Diff line change 44# dependencies
55/node_modules /
66
7- # test
8- / test /
7+ # env
8+ .env
Original file line number Diff line number Diff line change 1212 "build:lint" : " biome check ." ,
1313 "build:ts" : " tsup ./src" ,
1414 "lint" : " biome check --apply ." ,
15- "test" : " tsnd ./test/index.ts" ,
15+ "test" : " node --env-file=.env -r ts-node/register" ,
16+ "test:list" : " npm run test ./test/list.test.ts" ,
17+ "test:create" : " npm run test ./test/create.test.ts" ,
18+ "test:delete" : " npm run test ./test/delete.test.ts" ,
19+ "test:mime" : " npm run test ./test/mimetypes.test.ts" ,
1620 "prepare" : " husky"
1721 },
1822 "engines" : {
Original file line number Diff line number Diff line change 1+ import { type CreateObjectType , MimeTypes } from "../src" ;
2+ import { blob } from "./index.test" ;
3+
4+ // Create object using absolute path
5+
6+ const createWithPathPayload : CreateObjectType = {
7+ file : "package.json" ,
8+ name : "testing" ,
9+ } ;
10+
11+ blob . objects . create ( createWithPathPayload ) . then ( console . log ) ;
12+
13+ // Create object using buffer
14+
15+ const createWithBufferPayload : CreateObjectType = {
16+ file : Buffer . from ( "content" . repeat ( 1000 ) ) ,
17+ name : "testing" ,
18+ mimeType : MimeTypes . TEXT_PLAIN ,
19+ } ;
20+
21+ blob . objects . create ( createWithBufferPayload ) . then ( console . log ) ;
Original file line number Diff line number Diff line change 1+ import { blob } from "./index.test" ;
2+
3+ const objectsToDelete : string [ ] = [ ] ;
4+
5+ // Delete objects
6+
7+ blob . objects . delete ( objectsToDelete ) . then ( console . log ) ;
Original file line number Diff line number Diff line change 1+ import { SquareCloudBlob } from "../src" ;
2+
3+ export const blob = new SquareCloudBlob (
4+ process . env . SQUARECLOUD_API_KEY as string ,
5+ ) ;
Original file line number Diff line number Diff line change 1+ import type { ListObjectsType } from "../src" ;
2+ import { blob } from "./index.test" ;
3+
4+ const listOptions : ListObjectsType = {
5+ prefix : "test" ,
6+ } ;
7+
8+ // List objects with filter by prefix
9+
10+ blob . objects . list ( listOptions ) . then ( console . log ) ;
11+
12+ // List all objects
13+
14+ blob . objects . list ( ) . then ( console . log ) ;
Original file line number Diff line number Diff line change 1+ import { MimeTypeUtil } from "../src" ;
2+
3+ // Get supported mime type for certain file extension
4+
5+ console . log ( MimeTypeUtil . fromExtension ( "png" ) ) ; // "image/png"
6+ console . log ( MimeTypeUtil . fromExtension ( "potato" ) ) ; // "text/plain" (unsupported, defaults to text/plain)
7+ console . log ( MimeTypeUtil . fromExtension ( "txt" ) ) ; // "text/plain"
8+ console . log ( MimeTypeUtil . fromExtension ( "wav" ) ) ; // "audio/wav"
9+ console . log ( MimeTypeUtil . fromExtension ( "md" ) ) ; // "text/plain" (unsupported, defaults to text/plain)
10+ console . log ( MimeTypeUtil . fromExtension ( "json" ) ) ; // "application/json"
You can’t perform that action at this time.
0 commit comments