Flex: 使用URLRequest下载文件时的权限验证

Categories: Flex; Tagged with: ; @ January 27th, 2010 23:49

权限验证:

var fileRef:FileReference = new FileReference();
		var request:URLRequest = new URLRequest(serviceUrl);

		request.method = URLRequestMethod.POST;
		var encoder : Base64Encoder = new Base64Encoder();
		encoder.encode(userName + ":" + password);
		request.requestHeaders.push(new URLRequestHeader("Authorization", "Basic " + encoder.toString())); // ** 增加认证信息

		fileRef.addEventListener(Event.OPEN, onFileDownloadBegin);
		fileRef.addEventListener(Event.COMPLETE, onFileDownloadComplete);
		fileRef.addEventListener(IOErrorEvent.IO_ERROR, onFileDownloadError);
		fileRef.addEventListener(Event.CANCEL, onFileDownLoadCancel);
		fileRef.download(request, getExportFileName(serviceUrl));

<->



// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.