react-component / react-component/upload

How to upload image to firebase

Open
#165 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
804
Forks
323
Avg merge
12m
Merged PRs (30d)
1

Description

Hello everyone!

I've been trying to implement firebase image upload using this library from antd.

Below is a function file which goes into the action prop in <Upload /> component.

export async function uploadImage(file) {
    const storage = firebase.storage()
    const metadata = {
        contentType: 'image/jpeg'
    }
    const storageRef = await storage.ref()
    const imageName = generateHashName()
    const imgFile = storageRef.child(`Vince Wear/${imageName}.png`)
    const uploadTask = await imgFile.put(file, metadata)

    return new Promise((resolve, reject) => {
        return resolve(uploadTask)
    })
}

I can find the uploaded images from firebase but it always returns an error and looks like firebase is returning status of 501, Odd.

And this to the console

XML Parsing Error: syntax error 
Location: http://localhost:3000/upload.do 
Line Number 1, Column 1:

Is this a common issue? Any way to avoid it?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Upload component's action prop and the uploadImage function shown in the issue, then reproduce the Firebase Storage request and inspect the 501 response and localhost:3000/upload.do XML error. Done means identifying whether the failure is in this library's upload handling and documenting a confirmed resolution.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.