avatar upload with sfs2x

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

grhwood
Posts: 116
Joined: 15 Mar 2011, 04:43

avatar upload with sfs2x

Postby grhwood » 18 Nov 2013, 10:24

Hi,

Is it possible to upload avatar (<512Kb) with sfs2x ? Now I have another webservice to handle avatar upload but it will be great if I can use sfs only (with port 9933)

Thanks
User avatar
Lapo
Site Admin
Posts: 21680
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: avatar upload with sfs2x

Postby Lapo » 18 Nov 2013, 13:44

Yes, you can send byte arrays with the protocol so in essence you can transfer any file
See the SFSObject putByteArray method:

Code: Select all

SFSObject.putByteArray("avatarImage", byteData);
Lapo
--
gotoAndPlay()
...addicted to flash games
grhwood
Posts: 116
Joined: 15 Mar 2011, 04:43

Re: avatar upload with sfs2x

Postby grhwood » 18 Nov 2013, 19:33

Hi Lapo,

Thank for your response. But I wonder this is safe or not, since with http file upload, the file data is stored on disk so it will prevent out of memory. With your suggestion, if 1000 users upload a 512Kb avatar then it will cost alot of memory.

Thanks,
Nghia
User avatar
Lapo
Site Admin
Posts: 21680
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: avatar upload with sfs2x

Postby Lapo » 18 Nov 2013, 20:13

I wasn't implying that the data should be kept in memory.
Once the server side Extension receives the bytes of an avatar it should store it on disk, or database.
Lapo

--

gotoAndPlay()

...addicted to flash games
grhwood
Posts: 116
Joined: 15 Mar 2011, 04:43

Re: avatar upload with sfs2x

Postby grhwood » 19 Nov 2013, 17:35

Hi Lapo,

Code: Select all

SFSObject.putByteArray("avatarImage", byteData);


As server side extension received the byte[], so I think the avatar data is kept in memory when server side code handles it
User avatar
Lapo
Site Admin
Posts: 21680
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: avatar upload with sfs2x

Postby Lapo » 19 Nov 2013, 17:47

Well, not for long actually :)
Once you leave the handleClientRequest method the data is gone. So it's up to the developer to decide what to do while the data is in his hands, typically I would store it somewhere for later use.
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Google [Bot] and 35 guests