ShowpadLib.upload fails with extension csv
Is it possible to dynamically generate a CSV in an experience and upload to "My Files"?
When ever I do this it fails with a 400 error from the Showpad server.
Code to reproduce:
var filename = "export.csv";
const file = new File(["abc,def\n123,456"], filename);
const upload = {
file: file,
filename: filename
};
const statusEmitter = window.ShowpadLib.upload(upload);
statusEmitter.on('queued', () => {
console.log("queued")
});
statusEmitter.on('uploading', (data) => {
console.log("uploading")
});
statusEmitter.on('processing', () => {
console.log("processing")
});
statusEmitter.on('success', (data) => {
console.log("Success")
console.log(data)
});
statusEmitter.on('failed', (error) => {
console.log("failed")
console.log(error)
});
1/
In the simulator this gives a success message but is not really uploading the file (which is the expected behaviour).
2/
On the iPad, the save overlay shows the filename as export.csv. If the user tries to save this the upload fails.
If On the iPad the user changes the name in the overlay to export.txt the upload is a success.
If the code is changed so that the filename starts as export.txt the upload is a success.
3/ On the Windows app (running on win10) the overlay dialog just shows the filename as "export" and ignores the extension. This is fine as we only need this to work on an iPad, I am including it here so no one tries to replicate on this platform.
Surely we should be able to upload a simple text file with a csv extension?
Cheers
-
Official comment
Hi Malcom! Thanks for your post and your update. You are indeed correct that .csv is not on our list of supported file types, available here: https://help.showpad.com/hc/en-us/articles/211957069-Supported-file-types
You are also correct that Showpad support can enable all file types for accounts when requested through a ticket. If this applies to any of you readers out there, the Help button in the lower righthand corner will help you generate that request.
Love seeing your work around here, very inspiring to a young coder like myself. Thanks for writing and researching and following up!
-
OK so csv is not on the list of approved default filetypes [0]
Showpad support can enable "all filetypes" for me, but this isn't something I can make a call on for the org I'm working with.
So for anyone else who comes across this thread, I resolved it by adding the first line of the file as "sep=," and renaming as xls. It's a hacky workaround but it does work.[0] https://help.showpad.com/hc/en-us/articles/211957069-Supported-file-types
0
Please sign in to leave a comment.
Comments
2 comments