filepond icon indicating copy to clipboard operation
filepond copied to clipboard

File is of Invalid Type - Files prop doesn't support already processed mock files

Open rowrowrowrow opened this issue 6 years ago • 6 comments

Hey,

Thanks for your work. This is within a react application.

When I try to create a new FilePond instance and provide it a file prop from the controlled state of another FilePond instance it throws a 'File is of invalid type' error while looking like it attempts to make a get request to the current url + the source id or something. This only occurs when source FilePond state was created with a mock file. It looks like the mock file is processed and displayed correctly by the source FilePond but after post-processing by FilePond the mock file is not a Blob or File but a plain Object... so I think this issue is isolated to mock files. I'm unable to avoid passing a processed mock file.

Apologies if this is an issue you've already addressed.

Best,

rowrowrowrow

rowrowrowrow avatar Sep 23 '19 21:09 rowrowrowrow

I'm not sure I understand the issue, can you create a test case on codesandbox.io that would be very helpful.

rikschennink avatar Sep 24 '19 06:09 rikschennink

Sorry for the convoluted explanation. I'll work on an example if this psuedo-code doesn't help.

  1. const sourceFilePond = React.createElement(FilePond,{files : mockFiles});
  2. const processedMockFiles = sourceFilePondFiles; // Gathered from a parent component state of sourceFilePond
  3. let destinationFilePond = React.createElement(FilePond,{files : undefined});
  4. destinationFilePond = React.cloneElement(, {files:processedMockFiles });

rowrowrowrow avatar Sep 24 '19 18:09 rowrowrowrow

Please create an example

rikschennink avatar Sep 26 '19 06:09 rikschennink

Thanks for taking the time, I realized that this is the same issue as adding initial files using the addFiles method even though the files are passed as props. So I found a solution by recreating the initial files which is great.

But, not having to do that would be preferable :), e.g. if there was a way to specify/detect that the file was an initial mock file and not attempt to recreate/process it and whatever else happens. Of course I don't understand the implications of that as well as you but if you know of a way please let me know!!!!

rowrowrowrow avatar Sep 27 '19 22:09 rowrowrowrow

@rowrowrowrow I don't think that's possible, maybe you can add metadata and remove it when it's no longer a mock file?

rikschennink avatar Oct 01 '19 12:10 rikschennink

@rikschennink Ya I'm currently filtering mock vs. real using metadata because it's a simpler approach.

But, the processed mock file should have all the data to recreate itself internally or signal that it's an already processed mock file and prevent loading. E.g. I noticed the file property of a processed mock file is an Object and not a File or Blob... Something along these lines or just simply checking for a predetermined metadata property like 'isMockFile'. Happy to help work towards making this happen as I think it's weird that mock files can't persist like real files.

rowrowrowrow avatar Oct 01 '19 13:10 rowrowrowrow