diachedelic / capacitor-blob-writer

Capacitor plugin to write binary data to the filesystem
MIT License
132 stars 17 forks source link

BlobWriter does not respond to method call "get_config" #32

Closed jfbloom22 closed 3 years ago

jfbloom22 commented 3 years ago

I updated to version 1.0 and configured it in my iOS app. When I try to write I file I see this error:

 TO JS {"exif":{"LensSpecification":[3.2999999999999998,3.2999999999999998,2.3999999999999999,2.3999999999999999],"ExposureMode":0,"FocalLenIn35mmFilm":31,"CompositeImage":2,"Orientation":1,"ExifVersion":"0232","ISOSpeedRatings":[640],"DateTimeOriginal":"2021:05:
⚡️  To Native ->  BlobWriter get_config 83184517
⚡️  Error: Plugin BlobWriter does not respond to method call "get_config" using selector "get_config:".
⚡️  Ensure plugin method exists, uses @objc in its declaration, and arguments match selector without callbacks in CAP_PLUGIN_METHOD.
⚡️  Learn more: https://capacitorjs.com/docs/plugins/ios/#defining-methods
⚡️  To Native ->  Filesystem getUri 83184518
⚡️  TO JS {"uri":"file:\/\/\/var\/mobile\/Containers\/Data\/Application\/582604F8-6B15-4311-A81B-B03DCB16E521\/Documents\/media\/attachments\/26fb1d50-46c1-4eaa-a929-073398d6ff3f.jpeg"}

Here is the section of code I am using to call write_blob():

return fetch(fileSrc)
            .then(result => result.blob())
            .then(data => {
                attachment.type = data.type.replace(/^([a-z]+)\//, '');
                const fileExtension = data.type.replace(/^([a-z]+)\//, '');
                const cleanFilename = sanitizeFilename(attachment.fileName);
                attachment.fileName = `${cleanFilename}.${fileExtension}`;
                return write_blob({
                    path: `media/attachments/${attachment.guid}.${attachment.type}`,
                    directory: Directory.Data,
                    data,
                    recursive: true,
                    fallback: err => {
                        console.error(
                            'falling back to filesystem.writefile',
                            err
                        );

                        return true;
                    }
                }).then(result => {

When I test the code from https://github.com/diachedelic/capacitor-blob-writer/pull/30 writing the file works well.

diachedelic commented 3 years ago

I can place a breakpoint in get_config within Plugin.swift, and it is reached. Could you please try running npx cap sync and clean your Xcode build folder?

Note that the "fallback" option has been removed. Refer to the new "on_fallback" option in the docs.

jfbloom22 commented 3 years ago

Thx! followed those steps and I am no longer getting the error.