Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 152
Registered: ‎04-28-2012
My Device: BlackBerry 9800
My Carrier: BlackBerry

How to upload a file with some name?

[ Edited ]

Hi,

 

   I am able to upload the file to the server but i am not able to set the title for that file. After uploading it is showing "untitled". How can i achieve it? please help me.

 

QString url = "https://...?access_token=" + access_token;
	manager = new QNetworkAccessManager();
	QNetworkRequest request;
	request.setUrl(QUrl(url));
	request.setHeader(QNetworkRequest::ContentTypeHeader,"application/pdf");
	QFile file(QDir::homePath() + "/BB10_BBM_WebCast_2012.pdf");
	if(file.exists())
	{
		file.open(QIODevice::ReadOnly);
		QByteArray data;
		data.append(file.readAll());
		QFileInfo fileinfo(file);
		request.setHeader(QNetworkRequest::ContentDispositionHeader,QVariant(fileinfo.fileName()));
		qDebug()<<"the byte array is:"<<data.size()<<fileinfo.fileName();
		connect(manager, SIGNAL(finished(QNetworkReply *)), this,SLOT(onUpload(QNetworkReply *)));
		manager->post(request, data);
	}

 

 

Regards,

Naresh Kodumuri.

Developer
Posts: 1,280
Registered: ‎03-03-2011
My Device: Playbook, Z10, Q10, Z30 with Files & Folders and Orbit of course
My Carrier: Vodafone

Re: How to upload a file with some name?

It is put in the content-disposition header (usually as filename=....), which the server should parse. It depends on the server whether that happens or not.

Files & Folders, the unified file & cloud manager for PlayBook and BB10 with SkyDrive, SugarSync, Box, Dropbox, Google Drive, Google Docs. Free 3-day trial! - Jon Webb - Innovatology - Utrecht, Netherlands
Developer
Posts: 152
Registered: ‎04-28-2012
My Device: BlackBerry 9800
My Carrier: BlackBerry

Re: How to upload a file with some name?

Hi,

 

 

      ContentDispositionHeader also not able to set the file name for the file. Any Idea?

 

 

Regards,

Naresh Kodumuri.

Highlighted
Developer
Posts: 1,280
Registered: ‎03-03-2011
My Device: Playbook, Z10, Q10, Z30 with Files & Folders and Orbit of course
My Carrier: Vodafone

Re: How to upload a file with some name?

Not without knowing more about the server. Is it your own server, running your own site? Or is it some third-party API that you are calling?

Files & Folders, the unified file & cloud manager for PlayBook and BB10 with SkyDrive, SugarSync, Box, Dropbox, Google Drive, Google Docs. Free 3-day trial! - Jon Webb - Innovatology - Utrecht, Netherlands