This is a fork that is used to be able to support Absinthe's way of handling file uploads
Reversibly extracts files from an object tree.
Files are extracted along with their object path to allow reassembly. Extracted files are removed from the tree. Array item files are removed without reindexing the array to simplify reassembly.
Install with npm:
npm install extract-files
extractFiles accepts an object tree to extract files from, along with an optional tree path to prefix file paths:
const files =
Extracted files are an array:
path: 'tree.foo'file: /* File instance */path: 'tree.bar.0'file: /* File instance */path: 'tree.bar.1'file: /* File instance */
extractFiles will return an empty array if the object tree is
null or not an object. The top tree node must not be a file.
React Native polyfills FormData under the hood and objects with the properties
window.File. It would be risky to assume all objects with those properties in a tree are files. Use
ReactNativeFile instances within a tree to explicitly mark files:
const tree =singleFile:uri: uriFromCameraRolltype: 'image/jpeg'name: 'photo.jpg'multipleFiles: ReactNativeFileconst files =
object-path can be used to loop and reinsert the extracted files:
const files =const treePath =files
FileList instances in an original tree become arrays when reassembled.
- > 2% market share browsers.
- React Native.