Flash File Writing

10 views
Skip to first unread message

Nate

unread,
Jun 7, 2008, 5:02:25 PM6/7/08
to Google App Engine
I have a flash application that uses the Flash 8 FileReference class
to create an image file on the local disk. This doesn't seem to be
working on my Google App Engine website. I would assume there are
restrictions on who/what can dynamically create files on disk like
this. Is there a way around this restriction or a way to grant the
flash application the appropriate file creation privileges? I'm
really curious because this feature is key to the web application I
would like to build. I was really excited about the stability and
scalability that the app engine offers, but if this is not possible I
will have to consider other options.

Any help would be appreciated.
-Nate

nchauvat

unread,
Jun 7, 2008, 6:03:10 PM6/7/08
to Google App Engine
> I have a flash application that uses the Flash 8 FileReference class
> to create an image file on the local disk.  This doesn't seem to be
> working on my Google App Engine website.  I would assume there are
> restrictions on who/what can dynamically create files on disk like
> this.

There are restrictions: http://code.google.com/appengine/docs/python/sandbox.html

Maybe you could get some other server to generate the file for you and
link to it. Or generate the file on the fly and store it in memcache
for as long as it is going to be valid.

Raffaele Sena

unread,
Jun 7, 2008, 6:22:04 PM6/7/08
to google-a...@googlegroups.com
I don't think the appengine restrictions have anything to do with what
the Flash application can do (since appengine controls what you can do
on the Google servers and not what you can do on the client).

Unless you say that the same Flash application runs just fine if
hosted on a "standard" webserver, I would look at what the
requirements are for Flash to let you write a file on the client
computer.
Also, it could be you need to set the appropriate headers to tell the
application to download the file (Content-Disposition: attachment) or
something like that.

-- Raffaele

theillustratedlife

unread,
Jun 7, 2008, 6:22:19 PM6/7/08
to Google App Engine
Nate,

Flash Player runs locally (e.g. on the user's machine). Like an image
file, GAE will host it, but it is rendered on the user's machine. I
can't imagine GAE is the cause of the problems you are seeing. You're
probably bumping into Flash's security sandbox.

If you want to create an image server-side from Flash, you would need
a Python script that takes information POSTed from Flash and writes it
to a file.

Aral Balkan

unread,
Jun 7, 2008, 7:31:28 PM6/7/08
to Google App Engine
Hey Nate,

Check out the source files here: http://gaeswf.appspot.com. It should
demonstrate how to do what you're trying to do. (Basically, save a
ByteArray of the image in the datastore.

Aral

Nate

unread,
Jun 8, 2008, 10:49:50 AM6/8/08
to Google App Engine
Thanks for the feedback guys, I'll do some researching and see what I
come up with.

Nate

unread,
Jun 8, 2008, 4:00:05 PM6/8/08
to Google App Engine
So you guys were right. Since Flash is client side, it cannot create
a file on the server without the help from a script of some kind.
http://gaeswf.appspot.com/ contains some great examples for building
Flash apps on GAE. I found a good example of saving images to the
server but it's an implementation of PyAMF using the ByteArray class
with Django and Flex. I was not able to find a quick solution like a
simple python script so if anyone comes across that, let me know! I'm
very relieved to see that GAE can support this so thanks for the link!

Aral Balkan

unread,
Jun 8, 2008, 4:52:21 PM6/8/08
to Google App Engine
You're welcome -- glad to hear that you're finding it useful :)

Insofar as a simpler script goes, I'm not sure whether it would be
possible as ByteArray is basically the way to store images server side
and PyAMF provides native support for ByteArrays. So with anything
else you're going to have to implement your own serialization/de-
serialization which will probably end up complicating things more than
the Flash Remoting-based solution.

If you ignore the image rotation/cropping calculations in there, it's
simply a matter of converting the BitmapData instance to ByteArray,
making a remoting call to the server and, on the server side, saving
the ByteArray as a blob. You can then serve it back either as a
ByteArray or as a regular image by either going through PyAMF again or
by simply writing out an image in your handler.

Aral

On Jun 8, 9:00 pm, Nate <ncwe...@gmail.com> wrote:
> So you guys were right. Since Flash is client side, it cannot create
> a file on the server without the help from a script of some kind.http://gaeswf.appspot.com/contains some great examples for building

Raffaele Sena

unread,
Jun 8, 2008, 8:31:12 PM6/8/08
to google-a...@googlegroups.com
This is assuming you want to store some data displayed in the Flash movie.
If you want to upload a file stored on the client computer, I don't
think you can do it with Flash (at least not with Flash < 10). In
Flash 8/9 you can use a FileReference object to select a file from the
client computer and upload it, but you can't access the file data
before/instead of uploading.
Reply all
Reply to author
Forward
0 new messages