`

Error: EXDEV, Cross-device link

 
阅读更多

var exec = require("child_process").exec;

var querystring = require("querystring");

var fs = require("fs");

var util = require('util');

var formidable = require("formidable");

function start(response){
	console.log("request handler start was called ");
	
//	function sleep(milliSeconds){
//		var startTime = new Date().getTime();
//		while(new Date().getTime()<startTime+milliSeconds);
//		
//	}
//	sleep(10000);
	  var body = '<html>'+
	    '<head>'+
	    '<meta http-equiv="Content-Type" '+
	    'content="text/html; charset=UTF-8" />'+
	    '</head>'+
	    '<body>'+
	    '<form action="/upload" enctype="multipart/form-data" '+
	    'method="post">'+
	    '<input type="file" name="upload">'+
	    '<input type="submit" value="Upload file" />'+
	    '</form>'+
	    '</body>'+
	    '</html>';
//	 var body = '<html>'+
//	 '<head>'+
//	 '<meta http-equiv="Content-Type" content="text/html; '+
//	 'charset=utf-8" />'+
//	 '</head>'+
//	 '<body>'+
//	 '<form action="/upload" method="post">'+
//	 '<textarea name="text" rows="20" cols="60"></textarea>'+
//	 '<input type="submit" value="Submit text" />'+
//	 '</form>'+
//	 '</body>'+
//	 '</html>';
//	var content = "empty";
//	exec("echo %JAVA_HOME%",{timeout:10000,maxBuffer:20000*1024},function (error,stdout,stderr){
//		response.writeHead(200,{"Content-Type":"text/plain"});
//		response.write(stdout);
//		response.end();
//	});
	 
	response.writeHead(200,{"Content-Type":"text/html"});
	response.write(body);
	response.end();
	
}

function upload(response,request){
	console.log(" Request handler 'upload' was colled ");
	
	var form = new formidable.IncomingForm();
	console.log(" about to parse ");
	
	form.parse(request,function (error,fields,files){
		console.log("parsing done");


		var is = fs.createReadStream(files.upload.path)
		var os = fs.createWriteStream('/tmp/test.png');
	
		util.pump(is, os, function() {
		    fs.unlinkSync(files.upload.path);
		});
		
//		fs.renameSync(files.upload.path, "/tmp/test.png");
	    response.writeHead(200, {"Content-Type": "text/html"});
	    response.write("received image:<br/>");
	    response.write("<img src='/show' />");
	    response.end();
	});
	
//	response.writeHead(200, {"Content-Type": "text/plain;charset=utf-8"});
//	response.write("You've sent the text: "+querystring.parse(postData).text);
//	response.end();
}


function show(response,postData){
	console.log("Request handler 'show ' was called. ");
	fs.readFile("/tmp/test.png","binary",function(error,file){
		if(error){
			response.writeHead(500, {"Content-Type": "text/plain"});
		      response.write(error + "\n");
		      response.end();
		}else{
			 response.writeHead(200, {"Content-Type": "image/png"});
		      response.write(file, "binary");
		      response.end();
		}
	});
	
	
}

exports.start =start;
exports.upload = upload;
exports.show =show;

分享到:
评论

相关推荐

    nodejs提示:cross-device link not permitted, rename错误的解决方法

    Error: EXDEV: cross-device link not permitted, rename ‘C:\Users\THEDIS~1\AppData\Local\Temp\upload_9b46f1afc2f9ade074037c3fb707d271’ -&gt; ‘E:/node-rumen/tmp/test.png’ 文件上传的功能时候,调用fs....

    Node.js调用fs.renameSync报错(Error: EXDEV, cross-device link not permitted)

    在写一个文件上传的功能时候,调用fs.renameSync方法错误 出错 代码所在如下: ... form.parse(request, function(error, fields, files) { console.log("parsing done"); fs.renameSync(files.uploa

    vue单文件组件lint error自动fix与styleLint报错自动fix详解

    'error' : 'off', 'semi': 0, 'indent': 0, 'no-unused-vars': 0, }, }; ``` 这些规则定义了项目的基本编码风格,例如禁用了分号(`semi`),不强制缩进(`indent`),并允许在开发模式下使用`debugger`语句。 `...

    Linux操作系统错误代码解释_中英文对照

    OS error code 18: Invalid cross-device link 操作系统错误代码18:无效的跨设备链接 OS error code 19: No such device 操作系统错误代码19:没有这样的设备 OS error code 20: Not a directory 操作系统错误代码...

    Linux系统调用出错errno描述一览

    #### 18 EXDEV -- Invalid cross-device link 无效的跨设备链接。这通常发生在尝试移动一个文件到另一个不同设备的文件系统时。 #### 19 ENODEV -- No such device 找不到这样的设备。这通常发生在尝试访问一个不...

    Linux下errno.h文件错误号说明.docx

    * EXDEV (18):Cross-device link,表示跨设备链接。 * ENODEV (19):No such device,表示设备不存在。 * ENOTDIR (20):Not a directory,表示不是目录。 * EISDIR (21):Is a directory,表示是一个目录。 * ...

    linux命令返回值的含义解析

    18. OS error code 18: Invalid cross-device link - 交叉设备链接非法,如试图在两个不同的文件系统之间移动文件。 19. OS error code 19: No such device - 设备不存在。 20. OS error code 20: Not a directory -...

    JLink_Windows_V648.zip

    DLL: When using J-Trace PRO with IAR EWARM a "failed to allocate x bytes of memory" error could occur. Fixed. DLL: Windows: Renesas RX: When using FINE interface and disabling ongoining debug mode on ...

    Linux操作系统错误代码解释 (中英文对照).pdf

    OS error code 18: Invalid cross-device link** - **中文解释**:无效的跨设备链接 - **描述**:当尝试创建指向不同设备上的目标的符号链接时返回此错误。符号链接不能跨越不同的文件系统。 **20. OS error code...

    Linux操作系统错误代码解释-(中英文对照)

    19. **OS error code 18: Invalid cross-device link** - **操作系统错误代码18:无效的跨设备链接** - 当尝试创建一个跨越不同物理设备的硬链接时,会发生此错误。跨设备链接只能通过符号链接实现。 20. **OS ...

    Bochs - The cross platform IA-32 (x86) emulator

    - added 'pseudo device' in common USB code for the device creation. This makes the HCs independent from the device specific code. - USB MSD: added support for disk image modes (like ATA disks) - ...

    Senfore_DragDrop_v4.1

    For some strange reason the components causes a link error. * There appear to be sporadic problems compiling with C++ Builder 5. Several user have reported that they occasionally get one or more of...

    USB30 Universal Serial Bus 3.0 Specification pdf it is free

    732 Link Error Types, Detection, and Recovery 7-27 733 Header Packet Errors 7-27 7331 Packet Framing Error 7-27 7332 Header Packet Error 7-28 7333 Rx Header Sequence Number Error 7-28 734 Link Command...

    zynq_canutils.zip

    ARM(ZYNQ) cortexa9 Cross compiled CAN utils: To run CAN, use the below command: 1. Set bit-timing Can supports bitrates upto 1Mb/s. Xilinx CAN h/w and driver supports these bit rates Note: Triple ...

    Cognitive Radio Networks

    8.4.3 A Cross-Layer Power-Rate Control Scheme 268 8.4.4 Performance Evaluations 270 References 272 9 Network Layer Design 275 9.1 Routing in Mobile Ad-hoc Networks 275 9.1.1 Routing in Mobile Ad-hoc ...

    juery mobile使用ajax跨域请求服务器的小实例

    &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt; &lt;link rel="stylesheet" href="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css"&gt; &lt;script src="https://code.jquery...

    Professional.MFC.with.VC6

    The CDC Class and Device Contexts CDC Functions Metafiles CFont CPen CBitmap CBrush CPalette CRgn Stock Objects Splitter Windows The Different Kinds of Splitters Splitters and Performance ...

    uboott移植实验手册及技术文档

    实验三 移植U-Boot-1.3.1 实验 【实验目的】 了解 U-Boot-1.3.1 的代码结构,掌握其移植方法。 【实验环境】 1、Ubuntu 7.0.4发行版 2、u-boot-1.3.1 3、FS2410平台 4、交叉编译器 arm-softfloat-linux-gnu-...

Global site tag (gtag.js) - Google Analytics