Uploading file to SC

We have a need to upload an to a SC API using other software. We’re testing this by using curl but it doesn’t seem to work. The file uploads, but is not stored in the folder - we reflect the filename back in the response, and it is correct, so the upload does appear to be ok.

We have a very similar app connect form for uploading the file, and this works ok, but we need to be able to provide the ability to upload outside of a browser. I note that when uploaded through the App Connect form the File Upload task returns a value, where when it’s done through curl it returns null so the upload is failing at this stage to some degree.

Below is the SC action we have defined, and below that is the response that shows the file is uploaded (ie the filename is known) however the file is not stored in the folder.

Any hints from anyone who has done this, or knows more about how SC needs to receive files would be appreciated.

curl -v -X POST -F 'file=@/testfile.bin' https://example.org/dmxConnect/api/file/update.php

{"upload":null,"hello":"testfile.bin"}

Try this:

curl -X POST  https://example.org/dmxConnect/api/file/update.php -F 'file=@/testfile.bin'

Thanks for the suggestion, but unfortunately that does exactly the same thing. I think all you've done is to remove the verbose flag and change the order of the arguments though which I don't think should matter?

Ya, you’re right…I was taking my test and converting to your example.

Folder permissions? Path exists?

See if you can upload to my sandbox:

curl -X POST https://wappler.uniqueideas.com/dmxConnect/api/file_upload.php -F 'file1=@/testfile.bin'

It does a simple upload and works fine for me with postman and curl.

1 Like

Yep - this is all fine. I can upload to these folders if I use a form produced in Wappler.

You tell me :slight_smile:

Certainly this looks different than I see here as the file output is populated.

{"upload1":{"name":"testfile.bin","type":"application\/octet-stream","tmp_name":"\/home\/tos\/domains\/wappler.uniqueideas.com\/tmp\/php7WQbnc","error":0,"size":6560,"isFile":true,"processed":true,"path":"\/uploads\/testfile.bin","url":"\/uploads\/testfile.bin"}}

I'm guessing from this it probably did work - can you confirm?

I'll have another play here and see what I can see - thanks.

Yep, file uploaded just fine.

1 Like

It seems to be content related. The testfile I used to upload to your site isn’t the same as I’m using here - if I use the same file, I can upload it just fine to my site.

I was actually trying to upload a large JAR file - about 3MB. When I tried uploading this file through the form, it also fails… Previously I’d been testing with a smaller file - about 1MB - so it seems in some respects I picked a “bad” file. In other respects, this is still a useful test as our users will need to upload large files, so we still need to resolve this.

Playing with this some more, it seems I get some strange things happening with large file uploads - eg I see validation errors telling me a field is required, even though it is filled in (that was with a 10MB file, although there is a second 1MB file in the same form). If I change nothing in the form, other than choose a smaller file to upload, then this error goes away. I’ve seen this sort of thing in the past

Are there problems with large uploads with Wappler maybe?

Thanks for your help @mebeingken.

You might look at your server settings for this. Not sure of your server model, but php I believe defaults to 2mb max upload size.

I’m pretty sure I have this set to 10MB. I’ve certainly uploaded much larger files in the past, but not in a form with so many other fields…

I’ll check though - thanks.

Here are some other limits that you might be running into: max input parsing time, max execution time, max HTTP POST size, etc.

1 Like

That was the issue - thanks. We’ve recently migrated from a different (test) domain and I guess I didn’t change this on the new domain :sunglasses:

Thanks for your help (again :+1: )

1 Like