Re: [flexcoders] Flex Upload Handling (design)

2006-11-19 Thread Sebastian Zarzycki
hank williams wrote:

 This is a current failing in the flash/flex design.

 The way that I deal with it is to, before doing the actual upload, to 
 send the data associated with the upload to the server first. The 
 server then sends back an itemID or ticketID or something like that. 
 When you do the upload you send with the URL, a parameter which is 
 this new ID. The server knows that the thing that is being uploaded 
 must be associated with the ID. When the upload is done, the client 
 then knows what the ID of the uploaded item is and may ask the server 
 about the item or instruct the server to do some additional task(s) to 
 the item.


Ouch, not good to hear that.  I hope in future version Flex will be more 
hm... flexible in this matter (pun intended :)

However I admire your solution for the problem - I've been struggling 
with it for days, and haven't developed something like that. I'll 
definitely use this approach  in our project. The only thing now is to 
think how to reserve this itemID from the server. Guess I will have to 
create empty object, put in inside DB, get the ID and return it. When 
the real upload comes, the object will be just updated with proper data 
in DB. So far, so good :)

Thank you for your answer, it was really helpful.

-- 
| Software Engineer
| Sebastian Zarzycki
| Microplan Polska (http://www.microplan.pl)




--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* Your email settings:
Individual Email | Traditional

* To change settings online go to:
http://groups.yahoo.com/group/flexcoders/join
(Yahoo! ID required)

* To change settings via email:
mailto:[EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED]

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 



[flexcoders] Flex Upload Handling (design)

2006-11-18 Thread Sebastian Zarzycki
Hello there,

Here at Microplan we have some trouble with the design of project we're 
currently workin on. It's some kind of company recruitation system, 
built on Flex 2, exchanging data with tomcat server application via 
webservices.  Main part of the system is the ability to fill CV form, 
providing data about yourself, as well as attaching photo and additional 
documents (certificates, etc). This is the place where problems starts 
to appear.  This is more of a design problem than Flex, perhaps, I don't 
know.  I'm sorry if the description might appear too detailed. I just 
would like to know the best approach. Perhaps it all can be narrowed to 
simple :
how can I get the server response, after launching 
FileReference.upload() in Flex?

Here is the scenario :

CV object  fields {
id : integer;
(... alot more here)
photoID : integer;
}

so in DB we have 'cv' table as well as 'attachments' table. The photoID 
in CV object points to the file (blob) in DB.

User sees available job positions. Her wants to apply for a specific 
position. He clicks the appropriate button, the CV form (new app state) 
pops in. New CV object is created with empty fields. User fills the 
form. User attaches own photo. He would like to see it on screen after 
it is uploaded.

How to achieve that?

 From what I've seen, Flex supports file upload/download only via 
FileReference.upload(URLRequest) method.  Fine. So I'm getting the 
FileReference handle to file on user disk. I cannot use the file 
(contents of file) just to display it on screen - flash security policy. 
So I have to upload it immediately to server, then somewhow get it back. 
So I have FileUpload servlet which takes the image stream and saves it 
to DB into 'attachments' table.  I also have FileDownload servlet which 
takes attachment id as a parameter, it searches for image in DB with 
that id, then spits it out. OK, so I'm launching 
FileReference.upload(url_to_my_servlet), the content is uploaded, the 
file is saved in DB.

The problem is that at this point I have no information about what 
happened with the file on serverside, and more important - i don't know 
the id that it was given to the new row (tuple) in the DB. Without that, 
I cannot display it for user. I also need it for the CV object, without 
it, I cannot save it to DB, when user will click submit CV button. The 
simplest, though maybe not most clean solution, would be to spit the ID 
to the servlet response stream in FileUpload , after the file has been 
saved to DB (and given the ID, so I have access to it) - however I'm 
unable to retrieve servlet result in Flex.

Apart from that, have you built applications that used files uploaded 
from users? How did you design that? What seems to be the best way?
I would be grateful for any help.

-- 
| Software Engineer
| Sebastian Zarzycki
| Microplan Polska (http://www.microplan.pl)



--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* Your email settings:
Individual Email | Traditional

* To change settings online go to:
http://groups.yahoo.com/group/flexcoders/join
(Yahoo! ID required)

* To change settings via email:
mailto:[EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED]

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 



Re: [flexcoders] Flex Upload Handling (design)

2006-11-18 Thread hank williams

This is a current failing in the flash/flex design.

The way that I deal with it is to, before doing the actual upload, to send
the data associated with the upload to the server first. The server then
sends back an itemID or ticketID or something like that. When you do the
upload you send with the URL, a parameter which is this new ID. The server
knows that the thing that is being uploaded must be associated with the ID.
When the upload is done, the client then knows what the ID of the uploaded
item is and may ask the server about the item or instruct the server to do
some additional task(s) to the item.

Regards,
Hank

On 11/18/06, Sebastian Zarzycki [EMAIL PROTECTED] wrote:


Hello there,

Here at Microplan we have some trouble with the design of project we're
currently workin on. It's some kind of company recruitation system,
built on Flex 2, exchanging data with tomcat server application via
webservices.  Main part of the system is the ability to fill CV form,
providing data about yourself, as well as attaching photo and additional
documents (certificates, etc). This is the place where problems starts
to appear.  This is more of a design problem than Flex, perhaps, I don't
know.  I'm sorry if the description might appear too detailed. I just
would like to know the best approach. Perhaps it all can be narrowed to
simple :
how can I get the server response, after launching
FileReference.upload() in Flex?

Here is the scenario :

CV object  fields {
id : integer;
(... alot more here)
photoID : integer;
}

so in DB we have 'cv' table as well as 'attachments' table. The photoID
in CV object points to the file (blob) in DB.

User sees available job positions. Her wants to apply for a specific
position. He clicks the appropriate button, the CV form (new app state)
pops in. New CV object is created with empty fields. User fills the
form. User attaches own photo. He would like to see it on screen after
it is uploaded.

How to achieve that?

From what I've seen, Flex supports file upload/download only via
FileReference.upload(URLRequest) method.  Fine. So I'm getting the
FileReference handle to file on user disk. I cannot use the file
(contents of file) just to display it on screen - flash security policy.
So I have to upload it immediately to server, then somewhow get it back.
So I have FileUpload servlet which takes the image stream and saves it
to DB into 'attachments' table.  I also have FileDownload servlet which
takes attachment id as a parameter, it searches for image in DB with
that id, then spits it out. OK, so I'm launching
FileReference.upload(url_to_my_servlet), the content is uploaded, the
file is saved in DB.

The problem is that at this point I have no information about what
happened with the file on serverside, and more important - i don't know
the id that it was given to the new row (tuple) in the DB. Without that,
I cannot display it for user. I also need it for the CV object, without
it, I cannot save it to DB, when user will click submit CV button. The
simplest, though maybe not most clean solution, would be to spit the ID
to the servlet response stream in FileUpload , after the file has been
saved to DB (and given the ID, so I have access to it) - however I'm
unable to retrieve servlet result in Flex.

Apart from that, have you built applications that used files uploaded
from users? How did you design that? What seems to be the best way?
I would be grateful for any help.

--
| Software Engineer
| Sebastian Zarzycki
| Microplan Polska (http://www.microplan.pl)



--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links