Attachments upload

55 views
Skip to first unread message

Hasan A Yousef

unread,
Nov 16, 2013, 5:15:51 AM11/16/13
to part...@googlegroups.com
Peter,
My question is of two parts, may they have one answer, any how:
1. How can I upload file from the website to the server directory.
2. How can I upload file to be sent with email, I saw http://docs.partialjs.com/FrameworkMail/#message.attachment but could not get how to recognize the file path and name from the client form.

Regards,
Hasan

Peter Širka

unread,
Nov 16, 2013, 9:36:55 AM11/16/13
to part...@googlegroups.com
Hi Hasan,

I found small error, but all works. In the attachment is an example.
I'll must update documentation about uploaded files.

For complete functionality, show all options:
console.log(controller.files[0]);
console.log(controller.files[0].__proto__);

Thanks!
example.zip

Hasan A Yousef

unread,
Nov 16, 2013, 11:40:45 PM11/16/13
to part...@googlegroups.com
Hi Peter,
I got an error as attached.

I already adjusted the email and password to be mine.

Regards,
Hasan
uploaderr.png

Peter Širka

unread,
Nov 17, 2013, 2:38:17 AM11/17/13
to part...@googlegroups.com
Hi Hasan,
You uploaded too large file. Specify maximum length of file:

framework.route('/', send_mail, ['upload'], 1024 * 20);

// or

framework
.route('/', send_mail, { flags: ['upload'], length: 1024 * 20 });
 

1024 * 20 (max. 20 kB file) = is maximum length of uploaded file.
Thanks.

Hasan A Yousef

unread,
Nov 17, 2013, 2:55:30 AM11/17/13
to part...@googlegroups.com
Hi Peter,
I got this error msg after uploaded the correct file size.: "408: Request Timeout"

Regards,
HAsan

Peter Širka

unread,
Nov 17, 2013, 3:04:59 AM11/17/13
to
Does the framework throws an error?
You can use Gmail SMTP or other?

// here is problem
message.send('smtp.gmail.com', { port: 465, secure: true, user: 'your e-mail', password: 'your password' }, function() {
    self.plain('OK');
});

Hasan A Yousef

unread,
Nov 17, 2013, 5:58:01 AM11/17/13
to part...@googlegroups.com
I already adjusted it before,, I suspect may be our company firewall affect it, I'll check from home, and update you.

meanwhile, this is an example of attaching document in the email, what if I want to upload a file is the serve, for example, if the user want to upload his photo, how this can be managed with partialjs.

Regards,
Hasan

Peter Širka

unread,
Nov 17, 2013, 7:05:06 AM11/17/13
to part...@googlegroups.com
Message has been deleted

Hasan A Yousef

unread,
Nov 17, 2013, 9:27:16 AM11/17/13
to part...@googlegroups.com
It worked, and sent me the attachment, but in the browser, this error msg appeared:
"408: Request Timeout"

Peter Širka

unread,
Nov 17, 2013, 11:12:43 AM11/17/13
to part...@googlegroups.com
Hasan,

if framework return a timeout then is not executed e.g.: self.view().
Is console writing some error?

Attach your example and I'll try to test it.
Thanks.

Hasan A Yousef

unread,
Nov 17, 2013, 11:41:55 AM11/17/13
to part...@googlegroups.com
attached the file, nothing is displayed in the console
attach.zip

Peter Širka

unread,
Nov 17, 2013, 12:26:53 PM11/17/13
to part...@googlegroups.com
I sent test e-mail with bind.txt attachment.
Code is OK on my computer, problem will be elsewhere.

Thanks.

Hasan A Yousef

unread,
Nov 17, 2013, 12:40:14 PM11/17/13
to part...@googlegroups.com
I got the attachment you sent

Peter Širka

unread,
Nov 17, 2013, 1:11:20 PM11/17/13
to part...@googlegroups.com
Hassan I tested this example on Windows 8 and all is alright.

Hasan Yousef

unread,
Dec 14, 2013, 11:21:25 AM12/14/13
to part...@googlegroups.com
Hi Peter,

I re-run this app at Ubuntu, and got the error in the attached, the code I run is the latest one, appear here: http://www.partialjs.com/forum/?place=msg%2Fpartialjs%2FNFaBrSjobUM%2F75nUw4HgkdsJ
just changed the password.

Regards,
Hasan

attach.png

Peter Širka

unread,
Dec 14, 2013, 6:58:33 PM12/14/13
to part...@googlegroups.com
Hi Hassan,
I fixed problem with mail in new version (in development now). Try to use.

Thanks!
test.zip

hasan...@gmail.com

unread,
Dec 15, 2013, 12:07:50 AM12/15/13
to part...@googlegroups.com
:( same error!

Peter Širka

unread,
Dec 15, 2013, 3:05:13 AM12/15/13
to part...@googlegroups.com
Try to catch error:

// Insert this code before message.send()
// And write me an error ...
mail.on('error', function(err) {
    console.log(err);
});

Hasan Yousef

unread,
Dec 15, 2013, 6:39:29 AM12/15/13
to part...@googlegroups.com
Attached...
err.png

Peter Širka

unread,
Dec 15, 2013, 7:06:50 AM12/15/13
to part...@googlegroups.com
Hasan thanks!
There was an error and I fixed it.

Your problem:
Access denied. Your SMTP server needs authorization.

Hasan Yousef

unread,
Dec 15, 2013, 8:02:05 AM12/15/13
to part...@googlegroups.com
fixed where? what shall I do :)

Peter Širka

unread,
Dec 15, 2013, 4:54:50 PM12/15/13
to part...@googlegroups.com
Your problem: Access denied. Your SMTP server needs authorization.

Example:
message.send('your.smtp.server.com', { user: 'hassan', password: '123456' });

If your problem will persist then - please send me to my e-mail your SMTP server login password and I'll try to test it or fix it.
Thanks.

Hasan Yousef

unread,
Dec 16, 2013, 7:30:02 AM12/16/13
to part...@googlegroups.com
I'm using Gmail.. anyhow, I emailed you my username and password for testing

Hasan Yousef

unread,
Dec 16, 2013, 10:42:07 AM12/16/13
to part...@googlegroups.com
Thanks Peter... it looks internet connection here is very poor, never worked in office, and requested 10 seconds "timeout: 10000"  to work in home :)

Hasan Yousef

unread,
Feb 5, 2014, 12:46:55 AM2/5/14
to tot...@googlegroups.com, part...@googlegroups.com
Hi Peter,,
I run the same function today, and got the below msg:
"
.write(string, encoding, offset, length) is deprecated. Use write(string[, offse
t[, length]][, encoding]) instead.
Error: 501 5.5.2 Cannot Decode response n3sm42416148wix.10 - gsmtp Error: 501 5.
5.2 Cannot Decode response n3sm42416148wix.10 - gsmtp
    at TLSSocket.<anonymous> (d:\Downloads\Downloads\attach\node_modules\partial
.js\mail.js:22:6795)
    at TLSSocket.EventEmitter.emit (events.js:126:20)
    at TLSSocket.<anonymous> (d:\Downloads\Downloads\attach\node_modules\partial
.js\mail.js:22:5542)
    at TLSSocket.EventEmitter.emit (events.js:126:20)
    at readableAddChunk (_stream_readable.js:156:16)
    at TLSSocket.Readable.push (_stream_readable.js:123:10)
    at TCP.onread (net.js:511:20)
--------------------------------------------------------------------
TypeError: Cannot call method 'emit' of null TypeError: Cannot call method 'emit
' of null
    at TLSSocket.<anonymous> (d:\Downloads\Downloads\attach\node_modules\partial
.js\mail.js:22:5542)
    at TLSSocket.EventEmitter.emit (events.js:126:20)
    at readableAddChunk (_stream_readable.js:156:16)
    at TLSSocket.Readable.push (_stream_readable.js:123:10)
    at TCP.onread (net.js:511:20)
--------------------------------------------------------------------

Hasan Yousef

unread,
Feb 5, 2014, 12:53:33 AM2/5/14
to tot...@googlegroups.com, part...@googlegroups.com
Hi Peter,
using totaljs mail, I want to attach a file from the following directory:

d:/myApplication/pdf/fname.pdf

I defined it as:
message.attachment('pdf/fname.pdf');

but got the below error msg:
"TypeError: Cannot call method 'destroy' of null TypeError: Cannot call method 'd
estroy' of null
    at null._onTimeout (d:\myApplication\node_modules
    at Timer.listOnTimeout (timers.js:132:15)
    at timers.js:141:29
    at process._tickCallback (node.js:664:11)


how to fix it.

Thanks

Peter Širka

unread,
Feb 5, 2014, 7:52:55 AM2/5/14
to tot...@googlegroups.com, part...@googlegroups.com
Thanks! I fixed it.
Reply all
Reply to author
Forward
0 new messages