我正在尝试研究如何使用 RNFetchBlob 上传多个图像。我正在使用图像的 base64 编码版本作为测试。这是我的要求:
const base64ImageData = "/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBwgHBgkIBwgKCgkLDRYPDQwM\nDRsUFRAWIB0iIiAdHx8kKDQsJCYxJx8fLT0tMTU3Ojo6Iys/RD84QzQ5OjcB\nCgoKDQwNGg8PGjclHyU3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3\nNzc3Nzc3Nzc3Nzc3Nzc3Nzc3N//AABEIAHcAnwMBEQACEQEDEQH/xAAcAAAC\nAwEBAQEAAAAAAAAAAAAEBgIFBwMBAAj/xABUEAABAwIEAgUECRAIBAcAAAAB\nAgMEBREABhIhEzEHFEFRYRUiI3EyNGJygZGxstEWGCQzNUJDUlRWc3SUobPS\nF1OCk7TB4fA2g5KjJTdERWN1ov/EABsBAQACAwEBAAAAAAAAAAAAAAABBQME\nBgIH/8QAOREAAgEBBAQLBwUAAwAAAAAAAAECAwQFETESIVFxEzIzQVJhkaGx\n0fAGFBUiNELBI3KBouEWNWL/2gAMAwEAAhEDEQA/AB4/SNI6QYNSodWpjDMU\nxg8pUd1QUdLre1z68Ae5Qo9LoFcRVafFe6zGZeWjiP6kn0auYsMAOac5y6nr\ngSIkdLchC21KQVXAKTywBn9DyrQ2KzTnmYshLiJTSkkybgELFttOAH/+kCoX\n9pxfjV9OAECuZVob1YqLrsaSXFyXFKIkWFyok7acAaArOUulhEBiIwpqO2ht\nBWTcgJFr4ATs40ql5grPlSoxXTIfjtKVw39KR5o2AtgBiolfOVaHT6ZTozZj\nBpTieMsqULuLuLi3dgCuzjERnVuBMqVNfWtoOISIylABN07nY88AE5Uc+oij\nOoptOcQiTJJWJRUbEJFiDYf7GAI5rqLecqGY9WipDUeS2tAYdKSSUuDcm/dg\nADJMeDlN2fUKTFXxSylBDzxUkgrHgMAX1UzK9mOkVClz4rSY7sZRXwlEKNiN\nrm+AFPKl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UNI7LbYAcMp\n0OPm/LVPqyH3oqVNrbDakhZ2cXvfbvwBQ9JEmHklVNhPpkyw8l1wLQUotukW\nIIPdgA3o9YiZ5oshxlUiGiLKtZelZUSlPqtywBPP0OJkjL4lPLfmIkym29KN\nKCkhKzft78AVXRxPhZzmT6aw1Ji2jhwuLUlfJY2sAMANOYctx8sZfqVWVJdk\npZjm7QSEkgkDnvgBCyVmen17M0OlMxZTK5YcaDi3EqCbtq3tbfAGntZFZguI\nlie6rgEOaS2Bq072vfwwBjlNzzTXZ8RpECYFKeQkEuotzHhgDY3uj1l1xxZq\nLg1qKrcIbXPrwBlOaM5U6BmSqQ3YUta2JTjZUl1IBIURcbYAaXOiSn5vbjV9\ndVlRjOisOcENpVo9GkAX7eWAP//Z\n"
const imgSrc = "data:image/jpeg;base64," + base64ImageData;
RNFetchBlob.fetch('POST', 'http://localhost:3000/test_upload', {
Authorization : "Bearer access-token",
otherHeader : "foo",
'Content-Type' : 'multipart/form-data',
}, [
// element with property `filename` will be transformed into `file` in form data
{ name : 'one', filename : 'testimage.jpeg', data: imgSrc},
// custom content type
{ name : 'two', filename : 'testimage.jpeg', data: base64ImageData},
]).then((resp) => {
console.log(resp)
}).catch((err) => {
console.log(err)
})
这是我的服务器作为请求正文收到的内容:
"--RNFetchBlob218752\r\n" +
"Content-Disposition: form-data; name=\"one\"; filename=\"testimage.jpeg\"\r\n" +
"Content-Type: application/octet-stream\r\n" +
"\r\n" +
"\r\n" +
"--RNFetchBlob218752\r\n" +
"Content-Disposition: form-data; name=\"two\"; filename=\"testimage.jpeg\"\r\n" +
"Content-Type: application/octet-stream\r\n" +
"\r\n" +
"\r\n" +
"--RNFetchBlob218752--\r\n"
所以问题是图像数据到哪里去了?
(请注意,base64 字符串肯定有效,因为我已经在我的演示应用程序中的 Image 标签中显示了它。另请注意,我正在测试包括它,并附加了“data:image/jpeg;base64”。)
非常欢迎任何帮助!