react-native-fetch-blob icon indicating copy to clipboard operation
react-native-fetch-blob copied to clipboard

File size reported from fs.stat does not match uploaded file size

Open vs-lance opened this issue 6 years ago • 0 comments

RN: 0.54 RNFB: 0.10.8 iOS 11 (Simulator and device)

let clip.uri = assets-library://asset/asset.JPG?id=9DC79222-EC93-45CA-9891-5D91AEDC5F7C&ext=JPG

let fd = new FormData()
let stats = await RNFetchBlob.fs.stat(clip.uri)
fileSize = stats.size
fileObj = {
	uri: clip.uri,
	type: clip.type,
	name: clip.name,
	filename: clip.name,
	data: RNFetchBlob.wrap(clip.uri),
}
fileuploadlist.push(fileObj)
fd.append(fileSize + "_" + timestamp, fileObj)

let localOptions = {
	method: "POST",
	headers: {
		"Content-Type": undefined,
		Accept: "application/json",
	},
	body: fd,
	file: fileuploadlist
}
try {
	return fetch(url, localOptions, callback)
} catch (e) {}

}

reported file size from fs.stat === 178,849 bytes actual uploaded file size === 395,394 bytes

It seems that RNFetchBlob is uploading an uncompressed version of the file. Is there a way to make RNFetchBlob either report the uncompressed size or better yet, upload the file that was stat'ed?

vs-lance avatar Apr 26 '18 23:04 vs-lance