react-native-pinch icon indicating copy to clipboard operation
react-native-pinch copied to clipboard

Support for blobs

Open ma-pe opened this issue 6 years ago • 0 comments

Thanks for open sourcing your library! :)

Blob-support for react-native's fetch was introduced in 0.54:

facebook/react-native#11417 facebook/react-native#11573

Blobs doesn't seem to work with your library though:

var blob = new Blob();
pinnedFetch('https://jsonplaceholder.typicode.com/posts/1', {
  method: 'PUT',
  body: blob,
  headers: {
    'Content-Type': 'application/octet-stream',
  },
  sslPinning: {[
    "my.certificate"
  ]},
})
.then(response => response.json())
.then(json => console.warn(json));

Leads to:

Exception '-[__NSDictionaryM dataUsingEncoding:]: unrecognized selector sent to instance 0x1c4239de0' was thrown while invoking fetch on target RNPinch with params (
    "https://jsonplaceholder.typicode.com/posts/1",
        {
        body =         {
            "_data" =             {
                blobId = "cc129bc0-f470-405f-80f8-2c115b404e76";
                lastModified = 1535620344891;
                offset = 0;
                size = 0;
                type = "";
            };
        };
        headers =         {
            "Content-Type" = "application/octet-stream";
        };
        method = PUT;
        sslPinning =         {
            certs =             (
                "my.certificate"
            );
        };
    },
    137
)

I need ssl pinning for all my request but haven't found a library featuring blob PUTs.

Any thoughts on how to support this?

ma-pe avatar Aug 30 '18 09:08 ma-pe