aspx文件使用什么服务器,使用aspx将文件发布到https服务器?

这是我通过HTTP发送文件到服务器的代码, 但我试图使用HTTPS传输,我尝试了使用它正在工作的参数传递值,但我不知道如何使用文件流进行编码, can有人能帮我解决这个我有SSL证书使用aspx将文件发布到https服务器?

void Sending() {

String iFileName = "video.mp4";

String lineEnd = "\r\n";

String twoHyphens = "--";

String boundary = "*****";

String Tag = "fSnd";

try {

Log.e(Tag, "Starting Http File Sending to URL");

// Open a HTTP connection to the URL

HttpURLConnection conn = (HttpURLConnection) connectURL

.openConnection();

// Allow Inputs

conn.setDoInput(true);

// Allow Outputs

conn.setDoOutput(true);

// Don't use a cached copy.

conn.setUseCaches(false);

// Use a post method.

conn.setRequestMethod("POST");

conn.setRequestProperty("Connection", "Keep-Alive");

conn.setRequestProperty("Content-Type",

"multipart/form-data;boundary=" + boundary);

DataOutputStream dos = new DataOutputStream(conn.getOutputStream());

dos.writeBytes(twoHyphens + boundary + lineEnd);

dos.writeBytes("Content-Disposition: form-data; name=\"title\""

+ lineEnd);

dos.writeBytes(lineEnd);

dos.writeBytes(Title);

dos.writeBytes(lineEnd);

dos.writeBytes(twoHyphens + boundary + lineEnd);

dos.writeBytes("Content-Disposition: form-data; name=\"description\""

+ lineEnd);

dos.writeBytes(lineEnd);

dos.writeBytes(Description);

dos.writeBytes(lineEnd);

dos.writeBytes(twoHyphens + boundary + lineEnd);

dos.writeBytes("Content-Disposition: form-data; name=\"uploadedfile\";filename=\""

+ iFileName + "\"" + lineEnd);

dos.writeBytes(lineEnd);

Log.e(Tag, "Headers are written");

// create a buffer of maximum size

int bytesAvailable = fileInputStream.available();

int maxBufferSize = 1024;

int bufferSize = Math.min(bytesAvailable, maxBufferSize);

byte[] buffer = new byte[bufferSize];

// read file and write it into form...

int bytesRead = fileInputStream.read(buffer, 0, bufferSize);

while (bytesRead > 0) {

dos.write(buffer, 0, bufferSize);

bytesAvailable = fileInputStream.available();

bufferSize = Math.min(bytesAvailable, maxBufferSize);

bytesRead = fileInputStream.read(buffer, 0, bufferSize);

}

dos.writeBytes(lineEnd);

dos.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd);

// close streams

fileInputStream.close();

dos.flush();

Log.e(Tag,

"File Sent, Response: "

+ String.valueOf(conn.getResponseCode()));

InputStream is = conn.getInputStream();

// retrieve the response from server

int ch;

StringBuffer b = new StringBuffer();

while ((ch = is.read()) != -1) {

b.append((char) ch);

}

String s = b.toString();

Log.i("Response", s);

dos.close();

} catch (MalformedURLException ex) {

Log.e(Tag, "URL error: " + ex.getMessage(), ex);

}

catch (IOException ioe) {

Log.e(Tag, "IO error: " + ioe.getMessage(), ioe);

}

}

2014-02-12

Gopi.cs

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值