We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
When uploading an array of images by url, how to add custom metadata do each image, like file name, tags, labels?
import {uploadFileGroup} from '@uploadcare/upload-client' const urls = [ 'https://example.com/903948384271/image.png', 'https://example.com/903948384282/image.png', 'https://example.com/903948384293/image.png', 'https://example.com/903948384302/image.png', 'https://example.com/903948384313/image.png', ] const {files} = await uploadFileGroup(urls, { publicKey: 'uploadCarePublicKey', store: 'auto', checkForUrlDuplicates: true, secureSignature: 'secureSignature', secureExpire: 'secureExpire', maxConcurrentRequests: 10, saveUrlForRecurrentUploads: true }) // RESULT files = [ { mimeType: 'image/jpeg', name: 'image.png', originalFilename: 'image.png', }, { mimeType: 'image/jpeg', name: 'image.png', originalFilename: 'image.png', }, { mimeType: 'image/jpeg', name: 'image.png', originalFilename: 'image.png', }, { mimeType: 'image/jpeg', name: 'image.png', originalFilename: 'image.png', }, { mimeType: 'image/jpeg', name: 'image.png', originalFilename: 'image.png', }, ]
The text was updated successfully, but these errors were encountered:
Hey @NafisRubio,
To set unique metadata per each file, you need to upload each file separately and then create a group from the list of UUIDs.
import { uploadFile, uploadFileGroup } from "@uploadcare/upload-client"; const urls = [ "https://example.com/903948384271/image.png", "https://example.com/903948384282/image.png", "https://example.com/903948384293/image.png", "https://example.com/903948384302/image.png", "https://example.com/903948384313/image.png", ]; const files = await Promise.all( urls.map((url) => uploadFile(url, { publicKey: "demopublickey", metadata: { foo: "bar" }, fileName: "image.png", }) ) ); const group = await uploadFileGroup( files.map((file) => file.uuid), { publicKey: "demopublickey" } );
Also, I want to note that maxConcurrentRequests only affects multipart uploads. Unfortunately, this is not mentioned in the documentation.
maxConcurrentRequests
Furthermore, we are missing a method for batched file uploads with concurrency, perhaps we should add it.
I also noticed that metadata property cannot be passed to uploadFileGroup, this is a bug which we will fix soon, thank you :)
metadata
uploadFileGroup
Sorry, something went wrong.
Hi @NafisRubio, here's a live demo of the above solution suggested by @nd0ut. Check it out https://codesandbox.io/s/funny-snow-6lcrv9?file=/src/index.js
No branches or pull requests
Question
When uploading an array of images by url, how to add custom metadata do each image, like file name, tags, labels?
The text was updated successfully, but these errors were encountered: