Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ MT-multithreading and servers » HttpRequest File Upload
Re: HttpRequest File Upload [message #39568 is a reply to message #39566] Sat, 30 March 2013 12:13 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
Brat wrote on Sat, 30 March 2013 06:50

Okay,
seems like the code only works because the Rapidshare API allows to override the filename with the "filname" parameter.
When I wand to upload a file to share-online.biz, i cant pass the filename as an parameter.

void fUpload::Upload(){
	Vector <String> session; // to store SESSION and ServerURL
	int64 Filesize;
	String ret;
	FileIn fi;
	if(file == ""){
		PromptOK("No File selected");
		return;
	}

	HttpRequest GetServer("http://www.share-online.biz/upv3_session.php");
	GetServer.POST();
	GetServer.Post("username", "USER");
	GetServer.Post("password", "PW");
	ret = GetServer.Execute();
	if(!GetServer.IsSuccess()){
		PromptOK("Couldnt find uploadserver");
		return;
	}
	session = Split(ret, ";");
	if(!fi.Open(file)){
		PromptOK("Couldnt open " + file);
		return;
	}
	Filesize = fi.GetSize();
	fi.Close();

	HttpRequest	req(session[1]);
	req.POST();
	req.Post("username", "USER");
	req.Post("password", "PW");
	req.Post("upload_session", session[0]);
	req.Post("chunk_no", "1");
	req.Post("chunk_number", "1");
	req.Post("filesize", AsString(Filesize));
	req.Post("fn", LoadFile(file));
	req.Post("finalize", "1");
	ret = req.Execute();
	if(!req.IsSuccess()){
		PromptOK("FAILED");
		PromptOK(req.GetErrorDesc());
		return;
	}
	
	PromptOK(ret);
}

The second request doesnt work cause there is no filename parameter. How can i pass the filename without a filename parameter?


I guess it this is really service specific, anyway I would dare to say that alternative to passing filename parameter would be "RESTfull" - pass it as part of url. Perhaps something like

HttpRequest req(session[1] + '/' + filename);

Anyway, once again, there is not firm standard...

Mirek
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: How to use Skylark on external server
Next Topic: [SOLVED] Fix some memory leak in IpAddrInfo
Goto Forum:
  


Current Time: Tue Jun 04 23:53:20 CEST 2024

Total time taken to generate the page: 0.02144 seconds