If what you mean by restart a failed download is to continue appending
data to the local file, continuing from where the fail happened, then
AFAIK the answer would be no.

But you can handle the errors and provide feedback to the user. It may
also be possible to automatically restart the download after a
failure, but I would have to check that out. In order to begin an
upload or download, the FlashPlayer security requires user activation
by either selecting the file to upload from the local file system or
the location and file name to save a download to on the local file
system - however, once the reference to the files (local or remote)
has been obtained, it may be possible to begin it again after a
failure, and just notify the user of a major error if it fails x
number of times consecutively.

I forgot before that I also use Flash to download .mov files (private
site I set up for my brother to distribute movies of his new baby girl
to the rest of the family) the largest so far is 93MB and it downloads
fine - dunno about upload though, because I wrote an FTP client for
him to do the uploads.

I'll look into the above after the weekend (busy diving), and post the
results to clarify, I'm pretty new to this group, and had a little
help from it so far, so would gladly give something back when I can :)

The Rails side is simple, and the Flash side isn't tough - examples
follow:

Rails

Controller

  def upload
    ModelClass.new.save_image( params )
  end

Model

  def save_image params
    data          = params[:Filedata]
    name        = params[:Filename]
    path          = File.join( "public" , "users" , params[:id] ,
"images" , name)

    # params[:Filedata] and params[:Filename] are sent automatically
from Flash
    # params[:id] is appended to the url: 
www.mysite.com/controller_name/method_name_in_model/id

    File.open(path,'wb') do |file|
      file.puts data.read
    end
  end

Flash/Flex

The place to look for anyone interested would be at the FileReference
class.

Create a FileReference instance and call the browse() method with a
FileFilter if necessary to filter to specific file types.

Once the user has selected a file to upload (or a file location and
name if downloading) the select Event is triggered, and you can then
send the file to the Rails Controller.

Here's some simple AS3 code:

private var _fileReference:FileReference = new FileReference();
private var _imageFilter:FileFilter = new FileFilter("Images (*.jpg,
*.jpeg, *.gif, *.png)", "*.jpg;*.jpeg;*.gif;*.png");
private var _uploadURL:String = "http://www.mysite.com/controller/
model_method/id_if_required";

private function upload():void
{
    _fileReference.addEventListener(Event.SELECT, select); // Add
additional event handlers to handle progress, security errors, IO
errors and of course file complete etc
    _fileReference.browse([_imageFilter]); // You can add as many
different filters as required within the array parameter
}

private function select( event:Event ):void
{
    _fileReference = FileReference(event.target);
   _fileReference.upload(new URLRequest(_uploadURL));
}

HTH

Paul

On Jul 23, 3:20 pm, Alan Gutierrez <a...@blogometer.com> wrote:
> paul h wrote:
> > On Jul 23, 4:11 am, Alan Gutierrez <a...@blogometer.com> wrote:
> >> Qin Qin wrote:
> >>> Marnen Laibow-Koser wrote:
> >>>> Alan Gutierrez wrote:
> >>>>> Marnen Laibow-Koser wrote:
> >>>> However you want to look at it, the point is that the HTTP upload option
> >>>> (or whatever the Flash side of the tool does) exists.
> >>>>> The OP wants to upload more than 4GB and I wouldn't trust HTTP to
> >>>>> transfer 4GB from a client to a server on a regular basis. There is no
> >>>>> way to resume a failed upload.
> >> Why not follow up on by looking at the Flash upload control at Dropbox
> >> that Marnen Laibow-Koser describes? See how fast it can upload 250MB,
> >> what it does if you interrupt the upload, etc.
>
>  > Flash/Flex (AS3 only) now have a File IO Class to handle uploads and
>  > downloads, I use it to upload images to member areas in my Rails App
>  > with no problem, but the file sizes are no bigger than about 250K -
>  > never tried anything larger, although you do get progress information
>  > sent back to the event handler in flash so you can provide a progress
>  > information, and also handle any errors during the upload/download.
>
> Can it restart a failed download do you know?
>
> --
> Alan Gutierrez - a...@blogometer.com -http://twitter.com/bigeasy

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to