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

Cannot read property 'debug' of undefined #10

Closed
heiseish opened this issue Aug 27, 2016 · 18 comments
Closed

Cannot read property 'debug' of undefined #10

heiseish opened this issue Aug 27, 2016 · 18 comments

Comments

@heiseish
Copy link

heiseish commented Aug 27, 2016

Hi, I'm trying to use firestack mainly to upload picture onto firebase storage.
My model firestack file:
import Firestack from 'react-native-firestack' const firestack = new Firestack(); firestack.setStorageUrl(someUrl).then(() => console.log("Project configured and ready to boot")); module.exports = firestack;

and in my main file i just require it as normal:
var firestack = require('../../Model/firestack');
But when i run, it keep throwing this error:
screen shot 2016-08-27 at 5 58 50 pm

dependencies i use:
"react-native-firestack": "^2.1.0", "firebase": "^3.3.0", "react": "^15.2.1", "react-native": "0.31.0",
Any help would be greatly appreciated!

@auser
Copy link
Contributor

auser commented Aug 28, 2016

Ah interesting you're handling it with a model like that...

But ANYWAY, the latest version only works on iOS and I just pushed a fix for the bug you're seeing. That's because you're not passing an object (even an empty object) in to the constructor of Firestack. Try it again with the latest master branch, if you would.

@heiseish
Copy link
Author

heiseish commented Aug 28, 2016

@auser Hi thanks for the response! The previous problem has been resolved but there is a new one.
screen shot 2016-08-28 at 5 49 57 pm

@auser
Copy link
Contributor

auser commented Aug 28, 2016

Ah! The docs need to be updated. If you pass a storageBucket in the config of the Firestack() constructor, this happens automatically. I can update it to pass the setStorageUrl() on the firestack object.

Right now it's exposed through a different "object" and you can call setStorageUrl() like this:

firestack.storage.setStorageUrl()`

Do you think it makes sense to expose the setStorageUrl() function through on firestack as well?

@heiseish
Copy link
Author

heiseish commented Aug 29, 2016

Hi, thank you for the clarification. I figured that all functions related to storage should have a .storage preceedingly (ie uploadFile). I think it makes sense to have setStorageUrl() inside storage, since there is already the firestack constructor to take in the storage URL.
Right now when i try to pass the storage Url to firestack.storage.setStorageUrl() it keeps throwing this error something weird happened, but it works fine if I pass the config to the constructor instead.

Nevertheless, the uploadFile function throws an err
There was an error uploading the file, {} Cannot read property 'call' of undefined TypeError: Cannot read property 'call' of undefined
My storage permission has been set to public, and I'm fetching the image path by using the module react-native-image-picker with showImagePicker() function.

Any idea on this?

@auser
Copy link
Contributor

auser commented Aug 29, 2016

Ah... I don't think that is your error. Actually, this is a bug in the Firestack.Storage iOS class.

Give me a few minutes to update the class.

@auser
Copy link
Contributor

auser commented Aug 29, 2016

Okay, can you try now from the master branch?

You can call setStorageUrl() or pass the storageBucket in the configuration and it should just work.

@heiseish
Copy link
Author

Hi,
firestack.storage.setStorageUrl(someUrl).then(()=>{}) doesn't seem to work (keep throwing this error cannot read property then of undefined. I check the source code and see it no longer returns prosimify (..) and the way I did was i removed all the then in all storage functions so it doesnt throw an error on start up. Without the then(function), the simulator runs without any error but the uploading doesn't seem to work (ie file is not uploaded onto firebase storage)

Just in case May I double check if firestack does upload image from path? According to this, react native doesn't support file or blob types, so uploading images might not be straightforward yet.

@auser
Copy link
Contributor

auser commented Aug 29, 2016

Yep, I just tested it here... want to try one more time? (I just pushed one more update)

Also, if you're interested, I'm in the gutter room https://gitter.im/fullstackreact/react-native-firestack

@heiseish
Copy link
Author

may I see your example please?

@auser
Copy link
Contributor

auser commented Aug 29, 2016

Of course.

// The takePicture function
takePicture() {
    this.camera.capture()
      .then(({path}) => {
        const filename = 'photo.jpg'
        firestack.uploadFile(`photos/${filename}`, path, {
          contentType: 'image/jpeg',
          contentEncoding: 'base64',
        })
        .then((res) => {
          console.log('result from upload file: ', res);
        })
        .catch((err) => {
          console.log('error happened with uploadFile', err);
        })
      })
      .catch(err => console.error(err));
  }

and the render view

        <Camera
          ref={(cam) => {
            this.camera = cam;
          }}
          captureTarget={Camera.constants.CaptureTarget.temp}
          style={styles.preview}
          aspect={Camera.constants.Aspect.fill}>
          <Text style={styles.capture} onPress={this.takePicture.bind(this)}>[CAPTURE]</Text>
        </Camera>

@heiseish
Copy link
Author

Thank you! I will try again later and tell you the result.

@auser
Copy link
Contributor

auser commented Aug 29, 2016

Great. I also updated the README with the example.

@heiseish
Copy link
Author

Hi, I try the example and it throws
ExceptionsManager.js:76 Exception '*** setObjectForKey: key cannot be nil' was thrown while invoking uploadFile on target FirestackStorage with params ( "gs://someURL", "photos/${filename}", "/Users/G/Library/Developer/CoreSimulator/Devices/6AF0B403-BEAE-43B0-8B6B-A369B4384691/data/Containers/Data/Application/C8FB519B-4C67-4685-BB91-CD9DCE8DCE36/tmp/194308E8-4B18-4CD1-98FB-A8B6C3B5D8EE-32599-0003BFB508C9085F.jpg", { contentEncoding = base64; contentType = "image/jpeg"; }, 39 )

I think it's the issue with facebook fetching function.

@auser
Copy link
Contributor

auser commented Aug 29, 2016

Hm... did your file get uploaded? Do you see anything in the Xcode console?

I'm in the gittr room if you want more real-time discussion.

@heiseish
Copy link
Author

Hi, I'm in the middle of an lecture now so I'm afraid I can't talk rn.
The file didn't get uploaded but I will try rm rf, re-install the module and get back to you with the results later when i get home. Thank you for the help!

@auser
Copy link
Contributor

auser commented Aug 29, 2016

(Ah, well... gittr is a text-based chat room if you change your mind). I'm working on the Java side right now anyway... Perhaps you can gist me the Xcode logs stack, when you get a chance. I'd love to see what we can figure out.

@heiseish
Copy link
Author

Yup I will create a gist of Xcode logs if the problem still persists after re-installing.

@heiseish
Copy link
Author

@auser Hi, thank you very much for your help. I believe it's my silly mistake to not config firebase properly (ie adding firebase to the project). Please mark the issue as resolved.

With that said, this is such an awesome module! Can't wait to try it on android when full support comes out.

@auser auser closed this as completed Aug 29, 2016
Salakar added a commit that referenced this issue Dec 29, 2016
Fix JS reference memory leaks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants