-
Notifications
You must be signed in to change notification settings - Fork 2.1k
@uppy/provider-views: improve metadata handling in Google Photos Picker #5769
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
@uppy/provider-views: improve metadata handling in Google Photos Picker #5769
Conversation
…Picker - Extract metadata handling logic to dedicated function outside of map - Enhance code readability with clearer structure and comments - Ensure proper handling of createTime metadata - Improve type safety in metadata handling
Diff output filesdiff --git a/packages/@uppy/google-drive-picker/lib/GoogleDrivePicker.js b/packages/@uppy/google-drive-picker/lib/GoogleDrivePicker.js
index 5655ba9..6afc508 100644
--- a/packages/@uppy/google-drive-picker/lib/GoogleDrivePicker.js
+++ b/packages/@uppy/google-drive-picker/lib/GoogleDrivePicker.js
@@ -20,6 +20,7 @@ export default class GoogleDrivePicker extends UIPlugin {
id,
mimeType,
name,
+ platform,
...rest
} = _ref;
return {
@@ -36,10 +37,16 @@ export default class GoogleDrivePicker extends UIPlugin {
body: {
fileId: id,
accessToken,
- ...rest,
+ platform,
+ ...("url" in rest && {
+ url: rest.url,
+ }),
},
requestClientId: GoogleDrivePicker.requestClientId,
},
+ ...("metadata" in rest && {
+ meta: rest.metadata,
+ }),
};
}));
};
diff --git a/packages/@uppy/google-photos-picker/lib/GooglePhotosPicker.js b/packages/@uppy/google-photos-picker/lib/GooglePhotosPicker.js
index 7989e44..76a8f37 100644
--- a/packages/@uppy/google-photos-picker/lib/GooglePhotosPicker.js
+++ b/packages/@uppy/google-photos-picker/lib/GooglePhotosPicker.js
@@ -20,6 +20,7 @@ export default class GooglePhotosPicker extends UIPlugin {
id,
mimeType,
name,
+ platform,
...rest
} = _ref;
return {
@@ -36,10 +37,16 @@ export default class GooglePhotosPicker extends UIPlugin {
body: {
fileId: id,
accessToken,
- ...rest,
+ platform,
+ ...("url" in rest && {
+ url: rest.url,
+ }),
},
requestClientId: GooglePhotosPicker.requestClientId,
},
+ ...("metadata" in rest && {
+ meta: rest.metadata,
+ }),
};
}));
};
diff --git a/packages/@uppy/provider-views/lib/GooglePicker/googlePicker.js b/packages/@uppy/provider-views/lib/GooglePicker/googlePicker.js
index b727064..3f77d55 100644
--- a/packages/@uppy/provider-views/lib/GooglePicker/googlePicker.js
+++ b/packages/@uppy/provider-views/lib/GooglePicker/googlePicker.js
@@ -183,8 +183,14 @@ async function resolvePickedPhotos(_ref4) {
? [i]
: []
);
- return mediaItems.map(_ref5 => {
- let {
+ return mediaItems.map(mediaItem => {
+ var _mediaItem$mediaFile$,
+ _mediaItem$mediaFile$2,
+ _mediaItem$mediaFile$3,
+ _mediaItem$mediaFile$4,
+ _mediaItem$mediaFile$5,
+ _mediaItem$mediaFile$6;
+ const {
id,
type,
mediaFile: {
@@ -192,24 +198,56 @@ async function resolvePickedPhotos(_ref4) {
filename,
baseUrl,
},
- } = _ref5;
+ } = mediaItem;
return {
platform: "photos",
id,
mimeType,
url: type === "VIDEO" ? `${baseUrl}=dv` : `${baseUrl}=d`,
name: filename,
+ metadata: {
+ googlePhotosFileType: mediaItem.type,
+ createTime: mediaItem.createTime,
+ width: mediaItem.mediaFile.mediaFileMetadata.width,
+ height: mediaItem.mediaFile.mediaFileMetadata.height,
+ ...(mediaItem.type === "PHOTO" && {
+ cameraMake: (_mediaItem$mediaFile$ = mediaItem.mediaFile.mediaFileMetadata.photoMetadata) == null
+ ? void 0
+ : _mediaItem$mediaFile$.cameraMake,
+ cameraModel: (_mediaItem$mediaFile$2 = mediaItem.mediaFile.mediaFileMetadata.photoMetadata) == null
+ ? void 0
+ : _mediaItem$mediaFile$2.cameraModel,
+ focalLength: (_mediaItem$mediaFile$3 = mediaItem.mediaFile.mediaFileMetadata.photoMetadata) == null
+ ? void 0
+ : _mediaItem$mediaFile$3.focalLength,
+ apertureFNumber: (_mediaItem$mediaFile$4 = mediaItem.mediaFile.mediaFileMetadata.photoMetadata) == null
+ ? void 0
+ : _mediaItem$mediaFile$4.apertureFNumber,
+ isoEquivalent: (_mediaItem$mediaFile$5 = mediaItem.mediaFile.mediaFileMetadata.photoMetadata) == null
+ ? void 0
+ : _mediaItem$mediaFile$5.isoEquivalent,
+ exposureTime: (_mediaItem$mediaFile$6 = mediaItem.mediaFile.mediaFileMetadata.photoMetadata) == null
+ ? void 0
+ : _mediaItem$mediaFile$6.exposureTime,
+ }),
+ ...(mediaItem.type === "VIDEO" && {
+ cameraMake: mediaItem.mediaFile.mediaFileMetadata.videoMetadata.cameraMake,
+ cameraModel: mediaItem.mediaFile.mediaFileMetadata.videoMetadata.cameraModel,
+ fps: mediaItem.mediaFile.mediaFileMetadata.videoMetadata.fps,
+ processingStatus: mediaItem.mediaFile.mediaFileMetadata.videoMetadata.processingStatus,
+ }),
+ },
};
});
}
-export async function pollPickingSession(_ref6) {
+export async function pollPickingSession(_ref5) {
let {
pickingSessionRef,
accessTokenRef,
signal,
onFilesPicked,
onError,
- } = _ref6;
+ } = _ref5;
for (let interval = 1;;) {
try {
if (pickingSessionRef.current != null) { |
@mifi |
- remove usage of `any` - remove duplicated interface MediaMetadata (I don't see why ) - include `googlePhotosFileType` - fix `cameraMake` and `cameraModel` types - make videoMetadata,photoMetadata prop types from google optional (it seems that they really are, despite their API docs not saying so) - simplify
i've pushed some changes in two commits, let me know if that looks ok to you |
looking good! |
ok, looks good to me now. letting @Murderlon have a quick look too |
* main: Add useDropzone & useFileInput (#5735) build(deps): bump base-x from 3.0.9 to 3.0.11 (#5772) @uppy/provider-views: improve metadata handling in Google Photos Picker (#5769) Release: uppy@4.17.0 (#5771) fix: handle pagination for Google Photos picker (fixes #5765) (#5768) @uppy/companion: add max filename length env var (#5763) @uppy/core: fix missing required meta field error not updating (#5766) @uppy/screen-capture: add screenshot button (#5737) Update cs_CZ.ts (#5749)
* useWebcam: Revert "add helper to transform preact props to svelte" Add useDropzone & useFileInput (#5735) build(deps): bump base-x from 3.0.9 to 3.0.11 (#5772) @uppy/provider-views: improve metadata handling in Google Photos Picker (#5769) fix order Fix watch/build script not building components css fix svelte context add helper to transform preact props to svelte use context helpers Release: uppy@4.17.0 (#5771) fix: handle pagination for Google Photos picker (fixes #5765) (#5768) move generated components improve uppy context fix command @uppy/companion: add max filename length env var (#5763) @uppy/core: fix missing required meta field error not updating (#5766) @uppy/screen-capture: add screenshot button (#5737) Update cs_CZ.ts (#5749)
| Package | Version | Package | Version | | -------------------------- | ------- | -------------------------- | ------- | | @uppy/components | 0.2.0 | @uppy/remote-sources | 2.3.4 | | @uppy/core | 4.4.7 | @uppy/screen-capture | 4.3.1 | | @uppy/google-drive-picker | 0.3.6 | @uppy/svelte | 4.5.0 | | @uppy/google-photos-picker | 0.3.6 | @uppy/vue | 2.3.0 | | @uppy/locales | 4.6.0 | @uppy/webcam | 4.2.1 | | @uppy/provider-views | 4.4.5 | uppy | 4.18.0 | | @uppy/react | 4.4.0 | | | - meta: Remove remark reference from CI (Murderlon) - @uppy/components,@uppy/screen-capture: useScreenCapture fixes (Prakash / #5793) - examples: Add useRemoteSource (Merlijn Vos / #5778) - @uppy/components: Use webcam fixes2 (Mikael Finstad / #5791) - meta: Remove remark (Merlijn Vos / #5790) - meta: Delete old, unused files (Merlijn Vos / #5788) - meta: Sort package.json (Murderlon) - examples: Headless Hooks: Add useScreenCapture (Prakash / #5784) - @uppy/locales: Update pt_BR localization (Gabriel Pereira / #5780) - e2e: Skip for now then (Murderlon) - e2e: fixup! Fix CI for now (Murderlon) - e2e: Fix CI for now (Murderlon) - examples: Add useWebcam (Merlijn Vos / #5741) - @uppy/react,@uppy/svelte,@uppy/vue: Add useDropzone & useFileInput (Merlijn Vos / #5735) - meta: build(deps): bump base-x from 3.0.9 to 3.0.11 (dependabot[bot] / #5772) - @uppy/provider-views: improve metadata handling in Google Photos Picker (ben rosenbaum / #5769)
| Package | Version | Package | Version | | -------------------------- | ------- | -------------------------- | ------- | | @uppy/components | 0.2.0 | @uppy/remote-sources | 2.3.4 | | @uppy/core | 4.4.7 | @uppy/screen-capture | 4.3.1 | | @uppy/google-drive-picker | 0.3.6 | @uppy/svelte | 4.5.0 | | @uppy/google-photos-picker | 0.3.6 | @uppy/vue | 2.3.0 | | @uppy/locales | 4.6.0 | @uppy/webcam | 4.2.1 | | @uppy/provider-views | 4.4.5 | uppy | 4.18.0 | | @uppy/react | 4.4.0 | | | - meta: Remove remark reference from CI (Murderlon) - @uppy/components,@uppy/screen-capture: useScreenCapture fixes (Prakash / #5793) - examples: Add useRemoteSource (Merlijn Vos / #5778) - @uppy/components: Use webcam fixes2 (Mikael Finstad / #5791) - meta: Remove remark (Merlijn Vos / #5790) - meta: Delete old, unused files (Merlijn Vos / #5788) - meta: Sort package.json (Murderlon) - examples: Headless Hooks: Add useScreenCapture (Prakash / #5784) - @uppy/locales: Update pt_BR localization (Gabriel Pereira / #5780) - e2e: Skip for now then (Murderlon) - e2e: fixup! Fix CI for now (Murderlon) - e2e: Fix CI for now (Murderlon) - examples: Add useWebcam (Merlijn Vos / #5741) - @uppy/react,@uppy/svelte,@uppy/vue: Add useDropzone & useFileInput (Merlijn Vos / #5735) - meta: build(deps): bump base-x from 3.0.9 to 3.0.11 (dependabot[bot] / #5772) - @uppy/provider-views: improve metadata handling in Google Photos Picker (ben rosenbaum / #5769)
At our company, we're using Uppy as our file upload system, and we have validation logic that requires photos to meet minimum height and width requirements. To improve this process, I've enhanced the metadata handling for Google Photos picker to extract and organize all available metadata that Google provides.
Changes Made:
Improved Metadata Extraction: Updated the extractMediaMetadata function to more reliably extract metadata from photos and videos
Better Type Safety: Added proper TypeScript interfaces for photo and video metadata
Comprehensive Metadata Support: Now properly handling all metadata fields including:
Basic metadata: width, height, cameraMake, cameraModel
Photo-specific: focalLength, apertureFNumber, isoEquivalent, exposureTime
Video-specific: fps, processingStatus
Creation time
Benefits :
This feature will help users by:
Reducing the need for custom EXIF parsing on the client side
Providing all Google-supplied metadata directly in the Uppy object
Making validation of image dimensions more reliable and efficient
Supporting workflows that need photo metadata (like camera information)
Testing:
I've tested this enhancement with various types of photos and videos from Google Photos and confirmed that all available metadata is now properly extracted and included in the Uppy file object.