expo-file-system
Advanced tools
Comparing version 18.0.5 to 18.0.6
@@ -147,2 +147,6 @@ export declare class Directory { | ||
md5: string | null; | ||
/** | ||
* A mime type of the file. Null if the file does not exist or it cannot be read. | ||
*/ | ||
type: string | null; | ||
} | ||
@@ -149,0 +153,0 @@ export declare class FileHandle { |
@@ -15,2 +15,15 @@ import { ReadableStream, WritableStream } from 'web-streams-polyfill'; | ||
} | ||
export declare class FileBlob extends Blob { | ||
file: File; | ||
key: string; | ||
constructor(file: File); | ||
get size(): number; | ||
get name(): string; | ||
get type(): string; | ||
arrayBuffer(): Promise<ArrayBuffer>; | ||
text(): Promise<string>; | ||
bytes(): Promise<Uint8Array>; | ||
stream(): ReadableStream<Uint8Array>; | ||
slice(start?: number, end?: number, contentType?: string): Blob; | ||
} | ||
export declare class File extends ExpoFileSystem.FileSystemFile { | ||
@@ -26,2 +39,3 @@ /** | ||
constructor(...uris: (string | File | Directory)[]); | ||
blob(): Blob; | ||
get parentDirectory(): Directory; | ||
@@ -28,0 +42,0 @@ /** |
@@ -13,2 +13,8 @@ # Changelog | ||
## 18.0.6 — 2024-12-16 | ||
### 🎉 New features | ||
- [next] Add blob support and `.blob()` function. ([#33152](https://github.com/expo/expo/pull/33152) by [@aleqsio](https://github.com/aleqsio)) | ||
## 18.0.5 — 2024-12-10 | ||
@@ -15,0 +21,0 @@ |
{ | ||
"name": "expo-file-system", | ||
"version": "18.0.5", | ||
"version": "18.0.6", | ||
"description": "Provides access to the local file system on the device.", | ||
@@ -48,3 +48,3 @@ "main": "src/index.ts", | ||
}, | ||
"gitHead": "1faceb8d22bebee4571ef3a2f9578bec33dc26b1" | ||
"gitHead": "637acf537a92ac6209bfced71e097ba736b43fef" | ||
} |
@@ -169,2 +169,7 @@ export declare class Directory { | ||
md5: string | null; | ||
/** | ||
* A mime type of the file. Null if the file does not exist or it cannot be read. | ||
*/ | ||
type: string | null; | ||
} | ||
@@ -171,0 +176,0 @@ |
@@ -31,2 +31,44 @@ import { ReadableStream, WritableStream } from 'web-streams-polyfill'; | ||
export class FileBlob extends Blob { | ||
file: File; | ||
key: string = 'FileBlob'; | ||
constructor(file: File) { | ||
super(); | ||
this.file = file; | ||
} | ||
get size(): number { | ||
return this.file.size ?? 0; | ||
} | ||
get name(): string { | ||
return this.file.name; | ||
} | ||
get type(): string { | ||
return this.file.type ?? ''; | ||
} | ||
async arrayBuffer(): Promise<ArrayBuffer> { | ||
return this.file.bytes().buffer; | ||
} | ||
async text(): Promise<string> { | ||
return this.file.text(); | ||
} | ||
async bytes(): Promise<Uint8Array> { | ||
return this.file.bytes(); | ||
} | ||
stream(): ReadableStream<Uint8Array> { | ||
return this.file.readableStream(); | ||
} | ||
slice(start?: number, end?: number, contentType?: string): Blob { | ||
return new Blob([this.file.bytes().slice(start, end)], { type: contentType }); | ||
} | ||
} | ||
export class File extends ExpoFileSystem.FileSystemFile { | ||
@@ -47,2 +89,9 @@ /** | ||
/* | ||
* Returns the file as a Blob. The blob can be used in `@expo/fetch` to send files over network and for other uses. | ||
*/ | ||
blob(): Blob { | ||
return new FileBlob(this); | ||
} | ||
/* | ||
* Directory containing the file. | ||
@@ -49,0 +98,0 @@ */ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
310121
3218