Skip to content
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

feat(storage): pass file metadata through uploadFile to storage.put #720

Closed
georgeMorales opened this issue Jun 28, 2019 · 6 comments
Closed

Comments

@georgeMorales
Copy link

georgeMorales commented Jun 28, 2019

I'm doing login with facebook and when I enter the profile image in firebase storage I get a file with extension application / octet-stream, I need this file to have jpg, jpeg, png image format ... How can I put contentType?

const firebaseLib = getFirebase() const imageName = uuid.v4(); const path =${user.uid}/user_images`
const options = {
name: imageName,
};
const response = await urlToBlob(user.photoURL + '?type=large');

//upload the file to firebase storage
let uploadedFile = await firebaseLib.uploadFile(path, response, null, options)
// console.log('uploadedFile', uploadedFile);
// get url of image de firebase storage
let downloadURL = await uploadedFile.uploadTaskSnapshot.ref.getDownloadURL();
`

@prescottprue
Copy link
Owner

You can specify contentType as part of your call as shown in the firebase storage docs

@georgeMorales
Copy link
Author

Thank you for your reply @prescottprue ... Yes, I've tried it several times but it does not work.
const newMetadata = { contentType: 'image/jpeg' } let uploadedFile = await firebaseLib.uploadFile(path, response, newMetadata, options);

@prescottprue
Copy link
Owner

@JorgeMoralesLopez It actually appears that file metadata wasn't being passed along, so I started to work on that as a new feature for an upcoming version. The new syntax will look like so:

const storagePath = 'avatars'
const dbPath = 'avatarFilesInfo'
const fileMetadata = { contentType: 'image/jpeg' }

firebase
  .uploadFile(storagePath, file, dbPath, { metadata: fileMetadata })
  .then(() => {
    console.log('File uploaded successfully')
  })

@prescottprue prescottprue changed the title contentType uploadFile Storage feat(storage): pass file metadata through uploadFile to storage.put Jun 28, 2019
@georgeMorales
Copy link
Author

Thank you @prescottprue, I'm glad to hear that I was not on the wrong path because I searched the web and tried many ways.
If I upgrade to the new version, would I have to update other libraries like firebase, redux, react-redux, redux-firestore, thunk?

"firebase": "^5.4.1",
"react": "16.8.3",
"react-native": "https://github.com/expo/react-native/archive/sdk-33.0.0.tar.gz", (0.59 version)
"react-redux": "^5.0.7",
"react-redux-firebase": "^2.2.4",
"redux": "^4.0.0",
"redux-firestore": "^0.6.0",
"redux-thunk": "^2.3.0",

@prescottprue prescottprue mentioned this issue Jul 1, 2019
3 tasks
@prescottprue prescottprue added this to To do in v2.3.* via automation Jul 13, 2019
@prescottprue prescottprue modified the milestones: v3.0.*, v2.2.*, v2.3.* Jul 13, 2019
@prescottprue prescottprue moved this from To do to In progress in v2.3.* Jul 13, 2019
@prescottprue prescottprue moved this from In progress to Needs review in v2.3.* Jul 13, 2019
@prescottprue prescottprue moved this from Needs review to Reviewer approved in v2.3.* Jul 13, 2019
prescottprue added a commit that referenced this issue Jul 13, 2019
* feat(storage): pass file metadata through `uploadFile` to `storage.put` calls - #720
* fix(auth): pass `updateProfile` options to action - #701 - @cruzdanilo
* fix(profile): only include `providerData` if it is not an empty array in Firestore - #699
* feat(webpack): add `lodash-webpack-plugin` to shrink bundle size
@prescottprue
Copy link
Owner

prescottprue commented Jul 13, 2019

Fix included in v2.3.0 release including a docs update with an example. Reach out if it doesn't work as expected. Thanks for reporting!

Will release to next version soon

@prescottprue prescottprue added this to Done in v3.0.0 via automation Jul 13, 2019
v2.3.* automation moved this from Reviewer approved to Done Jul 13, 2019
@fuhrmannb
Copy link

I comment this issue because the feature was not released on next version.
Is it possible to add the feature also on the beta release?

@prescottprue prescottprue mentioned this issue Oct 2, 2019
3 tasks
prescottprue added a commit that referenced this issue Oct 5, 2019
* feat(types): add back type for `getFirebase` - #763
* feat(storage): pass file metadata through `uploadFile` to `storage.put` calls - #720
* feat(examples): update material and simple examples
* feat(docs): update docs with new hooks API
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
v2.3.*
  
Done
v3.0.0
  
Done
Development

No branches or pull requests

3 participants