Exemplo n.º 1
0
Arquivo: pic.js Projeto: fuufuuf/luan
        fs.readFile(newPath, function(err, data){
            avFile = new AV.File(picName, new Buffer(data));
            avFile.save().then(function() {
                console.log('AVFile fully saved');
                var Luan_photo_raw = AV.Object.extend("Luan_photo_raw");
                var pic = new Luan_photo_raw();
                pic.set("position", position);
                pic.set("image", avFile);

                pic.save(null, {
                    success: function(pic) {
                        // Execute any logic that should take place after the object is saved.
                        console.log('New object created with objectId: ' + pic.id);
                        res.locals.success = 'succeeded!!!';
                        res.render('upwork', { title: 'works!!!',
                            picID: pic.id });
                    },
                    error: function(pic, error) {
                        // Execute any logic that should take place if the save fails.
                        // error is a AV.Error with an error code and description.
                        err_mesg = 'Failed to create Luan_photo, with error code: ' + error.message;
                        console.log(err_mesg);
                        res.render('upfail', { err: err_mesg });
                    }
                });


            }, function(error) {
                // The file either could not be read, or could not be saved to AV.
                err_mesg = 'Failed to save AVFile with error code: ' + error.message;
                console.log(err_mesg);

                res.render('upfail', { err: err_mesg });
            });
        });
Exemplo n.º 2
0
	app.post('/test/upload', function(req, res){
		var base64Data = req.body.file_base64;
		base64Data = base64Data.replace(/^data:.*;base64,/,"");
		var file = new AV.File("14.png", {base64: base64Data});
		file.save({
			success: function(file){ //AV.File
				
			},
			error: function(error){
				console.log("error: ", error);
			}
		});
	});
Exemplo n.º 3
0
Arquivo: pic.js Projeto: fuufuuf/luan
        fs.readFile(newPath, function(err, data){
            avFile = new AV.File(picName, new Buffer(data));
            avFile.save().then(function() {
                console.log('AVFile fully saved');
               // var Luan_photo_Info = AV.Object.extend("Luan_photo_Info");
                var Luan_group_test = AV.Object.extend("Luan_group_test");
                var pic = new Luan_group_test();
                pic.set("P1", parseFloat(fields.p1));
                pic.set("P2", parseFloat(fields.p2));
                pic.set("P3", parseFloat(fields.p3));
                pic.set("P4", parseFloat(fields.p4));
                pic.set("P5", parseFloat(fields.p5));
                pic.set("type", fields.picType);
                pic.set("GroupID", parseInt(fields.groupID));
                pic.set("PhotoID", parseInt(fields.picID));
                pic.set("File", avFile);

                pic.save(null, {
                    success: function(pic) {
                        // Execute any logic that should take place after the object is saved.
                        console.log('New object created with objectId: ' + pic.id);
                        res.locals.success = 'succeeded!!!';
                        res.render('upwork', { title: 'upload!!!',
                            picID: pic.id });
                    },
                    error: function(pic, error) {
                        // Execute any logic that should take place if the save fails.
                        // error is a AV.Error with an error code and description.
                        err_mesg = 'Failed to create Luan_photo, with error code: ' + error.message;
                        console.log(err_mesg);
                        res.render('upfail', { err: err_mesg });
                    }
                });


            }, function(error) {
                // The file either could not be read, or could not be saved to AV.
                err_mesg = 'Failed to save AVFile with error code: ' + error.message;
                console.log(err_mesg);

                res.render('upfail', { err: err_mesg });
            });
        });