8000 feat(blob): expose more data by atinux · Pull Request #337 · nuxt-hub/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(blob): expose more data #337

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/content/1.docs/2.features/blob.md
Original file line number Diff line number Diff line change
Expand Up @@ -754,8 +754,10 @@ interface BlobObject {
pathname: string
contentType: string | undefined
size: number
uploadedAt: Date,
customMetadata?: Record<string, string> | undefined
httpEtag: string
uploadedAt: Date
httpMetadata: Record<string, string>
customMetadata: Record<string, string>
}
```

Expand Down
2 changes: 2 additions & 0 deletions src/runtime/blob/server/utils/blob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,9 @@ function mapR2ObjectToBlob(object: R2Object): BlobObject {
pathname: object.key,
contentType: object.httpMetadata?.contentType,
size: object.size,
httpEtag: object.httpEtag,
uploadedAt: object.uploaded,
httpMetadata: object.httpMetadata || {},
customMetadata: object.customMetadata || {}
}
}
Expand Down
12 changes: 10 additions & 2 deletions src/types/blob.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ReadableStream } from '@cloudflare/workers-types/experimental'
import type { ReadableStream, R2HTTPMetadata } from '@cloudflare/workers-types/experimental'
import type { MimeType } from '@uploadthing/mime-types'

// Credits from shared utils of https://github.com/pingdotgg/uploadthing
Expand All @@ -21,14 +21,22 @@ export interface BlobObject {
* The size of the blob in bytes.
*/
size: number
/**
* The blob's etag, in quotes so as to be returned as a header.
*/
httpEtag: string
/**
* The date the blob was uploaded at.
*/
uploadedAt: Date
/**
* The HTTP metadata of the blob.
*/
httpMetadata: R2HTTPMetadata
/**
* The custom metadata of the blob.
*/
customMetadata?: Record<string, string>
customMetadata: Record<string, string>
}

export interface BlobUploadedPart {
Expand Down
0