codelab-friendlychat-web icon indicating copy to clipboard operation
codelab-friendlychat-web copied to clipboard

image upload for the web app does not work

Open ghost opened this issue 10 years ago • 9 comments

Image upload does not work. when I pick an image the spinner goes on forever without uploading.. he is the console output: Failed to load resource: https://friendlychat-7f0bc.firebaseapp.com/null server responded with a status of 404 (Not Found)

If I sign out and sign in again the spinner keeps loading.. Also in order to upload the image, the image name has to start with "image", it would be better to check common extensions like .png, .jpg,..

ghost avatar May 21 '16 12:05 ghost

image api is down ... same problem

slotbite avatar May 23 '16 19:05 slotbite

Image file name issue

You can upload images with any names, we only restrict by MIME type:

<input id="mediaCapture" type="file" accept="image/*,capture=camera">

Can you confirm that your File picker only lets you choose with files that start with image ? On which Browser/Os is this happening?

404 error

Can you double check that the storageBucket URL is not empty in your Firebase initialization snippet (the thing you copy paste from the Firebase Console)? Can you also tell me on which Browser/OS this is happening? Are there any errors before the 404 error in the console?

If you can consistently reproduce this could you upload your app? (Just run firebase deploy and give us the URL...)

nicolasgarnier avatar May 23 '16 21:05 nicolasgarnier

@slotbite Could you tell em what you mean by "image api"? Give any details as you can please. Such as How to reproduce the issue. At which step o the codelab does this happens? etc...

nicolasgarnier avatar May 23 '16 21:05 nicolasgarnier

0hn1chmdpt

The response { "error": { "code": 403, "message": "Unauthorized request." } }

code: "storage/unauthorized", message: "Firebase Storage: User does not have permission to…4096759791/5888042d60b337419a73da08dc073c24.jpg'.", serverResponse: "{↵ "error": {↵ "code": 403,↵ "message": "Unauthorized request."↵ }↵}", name: "FirebaseError"} code : "storage/unauthorized" message : "Firebase Storage: User does not have permission to access 'ckn3ZtFKWNWwzc4JXVWVveKlvuE2/1464096759791/5888042d60b337419a73da08dc073c24.jpg'." name : "FirebaseError" serverResponse : "{↵ "error": {↵ "code": 403,↵ "message": "Unauthorized request."↵ }↵}"

Yesterday I worked, I did not have any change, so I think there is a problem with the storage rules firebase image

slotbite avatar May 24 '16 13:05 slotbite

Yes you are right, the rules are not correct, for them to work you need a userId in the path. See this file: https://github.com/firebase/friendlychat/blob/master/web/storage.rules

the second match line needs to be match /{userId}/{timestamp}/{fileName} { instead of match /{allPath=**} {

nicolasgarnier avatar May 24 '16 14:05 nicolasgarnier

Cool! Thanks you

slotbite avatar May 24 '16 14:05 slotbite

amazing, worked for me as well with a little variation: match /{userId}/{postId}/{fileName} {

Vincent05 avatar Apr 19 '17 09:04 Vincent05

Had the same problem, and the solution was to stop / restart the server "firebase serve", whereas previously throughout the sample code I was only reloading the web-page. HTH

plthatfunkymusic avatar Jun 21 '17 13:06 plthatfunkymusic

Cool! Thanks you

TuanMinPay avatar Jan 12 '18 16:01 TuanMinPay