Upload wav file to server


#1

Hi all,

i tried to upload file “testfile.wav” to my own server with POST method.

my code is

[CODE]
URL *url = new URL(“https://myserver/upload_file_from_plugin”);

*url = url->withParameter("user", "test");

File *file = new File("c:\testfile.wav");
*url = url->withFileToUpload("uploadfile", *file,"audio/wav");

juce::InputStream* input = url->createInputStream(true);

[/CODE]

the POST method is triggered but without my file.
i tried only with parameters, everythings is OK but withfileUpload, parameters disappears and file is nonexistent.

any ideas?

Thanks a lot :slight_smile:
Tomi


#2

Ouch! Done a lot of java programming? Please never ever create a File or URL on the heap, it makes my internal leak detector hurt!

Your problem may be as simple as the missing second backslash in your filename?


#3

Hi @jules
Thank you for your reply.

Ahah sorry for that :sweat:

sorry but i don’t understand “create a File/URL on the heap”. ^^

i tried to execute that on button click function :

	URL url = URL("https://myserver/upload_file_from_plugin");

	url = url.withParameter("user", "test");

	File file = File("c:\\testfile.wav"); // this file is already in my C disk
	url = url.withFileToUpload("uploadfile", file,"audio/wav");
	
	InputStream* input = url.createInputStream(true);

but nothing change.
In server-side, body is empty.

EDIT : My bad It was a server-side problem with my nodeJS server (and fileupload middleware) and maybe double backslash problem too.

i just have one last question for download callback :

how to use OpenStreamProgressCallback ? i need to create a function “cb” and put it in InputStream second parameter?

Thanks.