Making a download page

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
19 messages Options
Reply | Threaded
Open this post in threaded view
|

Making a download page

rjacas
Hi, i'm trying to make a simple downloading function from files
already in the server.
I was using the book's example but i cant make it work, because the
example already has the file in a variable, and i need to refer a file
in the system.
anyone got a simple solution?

Thanks beforehand for any help on this :)

--
lets reign all together
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Making a download page

littleSmalltalker
There are several options to this.
 - Upload all files to the file library in advance, and display them to the user. The FileLibrary also provides mechanism for loading new files, so there should be no problem to update it.
 - Load files from the filesystem into the filelibrary (using WAFileLibrary>>#addFile, or WAFileLibrary class >>#addFileAt: / addAllFilesIn: ).
 - There's a new option on Seaside 3.0.4 which allows you to specify a configuration value for file handlers that determines the base url of a file library. This way, your absolute urls would be: <base-url>/<file-library-name>/<file-name>

You can also refer to files directly on the filesystem, which doesn't require any FileLibrary support.


Avi.

On Tue, Mar 8, 2011 at 9:02 PM, Ricardo Jacas <[hidden email]> wrote:
Hi, i'm trying to make a simple downloading function from files
already in the server.
I was using the book's example but i cant make it work, because the
example already has the file in a variable, and i need to refer a file
in the system.
anyone got a simple solution?

Thanks beforehand for any help on this :)

--
lets reign all together
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: Making a download page

Robert Sirois
Then the web server would be serving them directly (nginx, apache, etc.), right?
 
I'm interested in this, too. I was gonna be looking at doing something similar to Dropbox or Base Camp.
 
RS
 

Date: Tue, 8 Mar 2011 22:19:53 +0200
Subject: Re: [Seaside] Making a download page
From: [hidden email]
To: [hidden email]

There are several options to this.
 - Upload all files to the file library in advance, and display them to the user. The FileLibrary also provides mechanism for loading new files, so there should be no problem to update it.
 - Load files from the filesystem into the filelibrary (using WAFileLibrary>>#addFile, or WAFileLibrary class >>#addFileAt: / addAllFilesIn: ).
 - There's a new option on Seaside 3.0.4 which allows you to specify a configuration value for file handlers that determines the base url of a file library. This way, your absolute urls would be: <base-url>/<file-library-name>/<file-name>

You can also refer to files directly on the filesystem, which doesn't require any FileLibrary support.


Avi.

On Tue, Mar 8, 2011 at 9:02 PM, Ricardo Jacas <[hidden email]> wrote:
Hi, i'm trying to make a simple downloading function from files
already in the server.
I was using the book's example but i cant make it work, because the
example already has the file in a variable, and i need to refer a file
in the system.
anyone got a simple solution?

Thanks beforehand for any help on this :)

--
lets reign all together
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Making a download page

littleSmalltalker
Serving them directly from a webserver can be performed in two ways:
1) completely detached from Seaside, where the links are simply external.
2) referenced by FileLibrary, but served through the webserver. This can be done using the new X-Sendfile functionality (using the base url as mentioned).


Avi.

On Tue, Mar 8, 2011 at 10:59 PM, Robert Sirois <[hidden email]> wrote:
Then the web server would be serving them directly (nginx, apache, etc.), right?
 
I'm interested in this, too. I was gonna be looking at doing something similar to Dropbox or Base Camp.
 
RS
 

Date: Tue, 8 Mar 2011 22:19:53 +0200
Subject: Re: [Seaside] Making a download page
From: [hidden email]
To: [hidden email]


There are several options to this.
 - Upload all files to the file library in advance, and display them to the user. The FileLibrary also provides mechanism for loading new files, so there should be no problem to update it.
 - Load files from the filesystem into the filelibrary (using WAFileLibrary>>#addFile, or WAFileLibrary class >>#addFileAt: / addAllFilesIn: ).
 - There's a new option on Seaside 3.0.4 which allows you to specify a configuration value for file handlers that determines the base url of a file library. This way, your absolute urls would be: <base-url>/<file-library-name>/<file-name>

You can also refer to files directly on the filesystem, which doesn't require any FileLibrary support.


Avi.

On Tue, Mar 8, 2011 at 9:02 PM, Ricardo Jacas <[hidden email]> wrote:
Hi, i'm trying to make a simple downloading function from files
already in the server.
I was using the book's example but i cant make it work, because the
example already has the file in a variable, and i need to refer a file
in the system.
anyone got a simple solution?

Thanks beforehand for any help on this :)

--
lets reign all together
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside



_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Making a download page

rjacas
thx Avi, i'll give it a try :)

2011/3/8 Avi Shefi <[hidden email]>:

> Serving them directly from a webserver can be performed in two ways:
> 1) completely detached from Seaside, where the links are simply external.
> 2) referenced by FileLibrary, but served through the webserver. This can be
> done using the new X-Sendfile functionality (using the base url as
> mentioned).
>
>
> Avi.
>
> On Tue, Mar 8, 2011 at 10:59 PM, Robert Sirois <[hidden email]>
> wrote:
>>
>> Then the web server would be serving them directly (nginx, apache, etc.),
>> right?
>>
>> I'm interested in this, too. I was gonna be looking at doing something
>> similar to Dropbox or Base Camp.
>>
>> RS
>>
>> ________________________________
>> Date: Tue, 8 Mar 2011 22:19:53 +0200
>> Subject: Re: [Seaside] Making a download page
>> From: [hidden email]
>> To: [hidden email]
>>
>> There are several options to this.
>>  - Upload all files to the file library in advance, and display them to
>> the user. The FileLibrary also provides mechanism for loading new files, so
>> there should be no problem to update it.
>>  - Load files from the filesystem into the filelibrary (using
>> WAFileLibrary>>#addFile, or WAFileLibrary class >>#addFileAt: /
>> addAllFilesIn: ).
>>  - There's a new option on Seaside 3.0.4 which allows you to specify a
>> configuration value for file handlers that determines the base url of a file
>> library. This way, your absolute urls would be:
>> <base-url>/<file-library-name>/<file-name>
>>
>> You can also refer to files directly on the filesystem, which doesn't
>> require any FileLibrary support.
>>
>>
>> Avi.
>>
>> On Tue, Mar 8, 2011 at 9:02 PM, Ricardo Jacas <[hidden email]>
>> wrote:
>>
>> Hi, i'm trying to make a simple downloading function from files
>> already in the server.
>> I was using the book's example but i cant make it work, because the
>> example already has the file in a variable, and i need to refer a file
>> in the system.
>> anyone got a simple solution?
>>
>> Thanks beforehand for any help on this :)
>>
>> --
>> lets reign all together
>> _______________________________________________
>> seaside mailing list
>> [hidden email]
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>
>>
>> _______________________________________________ seaside mailing list
>> [hidden email]
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>> _______________________________________________
>> seaside mailing list
>> [hidden email]
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>
>
>
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>



--
lets reign all together
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Making a download page

rjacas
how can i actually do the download?  i,ve been trying for hours.... :/

2011/3/8 Ricardo Jacas <[hidden email]>:

> thx Avi, i'll give it a try :)
>
> 2011/3/8 Avi Shefi <[hidden email]>:
>> Serving them directly from a webserver can be performed in two ways:
>> 1) completely detached from Seaside, where the links are simply external.
>> 2) referenced by FileLibrary, but served through the webserver. This can be
>> done using the new X-Sendfile functionality (using the base url as
>> mentioned).
>>
>>
>> Avi.
>>
>> On Tue, Mar 8, 2011 at 10:59 PM, Robert Sirois <[hidden email]>
>> wrote:
>>>
>>> Then the web server would be serving them directly (nginx, apache, etc.),
>>> right?
>>>
>>> I'm interested in this, too. I was gonna be looking at doing something
>>> similar to Dropbox or Base Camp.
>>>
>>> RS
>>>
>>> ________________________________
>>> Date: Tue, 8 Mar 2011 22:19:53 +0200
>>> Subject: Re: [Seaside] Making a download page
>>> From: [hidden email]
>>> To: [hidden email]
>>>
>>> There are several options to this.
>>>  - Upload all files to the file library in advance, and display them to
>>> the user. The FileLibrary also provides mechanism for loading new files, so
>>> there should be no problem to update it.
>>>  - Load files from the filesystem into the filelibrary (using
>>> WAFileLibrary>>#addFile, or WAFileLibrary class >>#addFileAt: /
>>> addAllFilesIn: ).
>>>  - There's a new option on Seaside 3.0.4 which allows you to specify a
>>> configuration value for file handlers that determines the base url of a file
>>> library. This way, your absolute urls would be:
>>> <base-url>/<file-library-name>/<file-name>
>>>
>>> You can also refer to files directly on the filesystem, which doesn't
>>> require any FileLibrary support.
>>>
>>>
>>> Avi.
>>>
>>> On Tue, Mar 8, 2011 at 9:02 PM, Ricardo Jacas <[hidden email]>
>>> wrote:
>>>
>>> Hi, i'm trying to make a simple downloading function from files
>>> already in the server.
>>> I was using the book's example but i cant make it work, because the
>>> example already has the file in a variable, and i need to refer a file
>>> in the system.
>>> anyone got a simple solution?
>>>
>>> Thanks beforehand for any help on this :)
>>>
>>> --
>>> lets reign all together
>>> _______________________________________________
>>> seaside mailing list
>>> [hidden email]
>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>>
>>>
>>> _______________________________________________ seaside mailing list
>>> [hidden email]
>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>> _______________________________________________
>>> seaside mailing list
>>> [hidden email]
>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>>
>>
>>
>> _______________________________________________
>> seaside mailing list
>> [hidden email]
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>
>>
>
>
>
> --
> lets reign all together
>



--
lets reign all together
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Making a download page

John McKeon
Ricardo,
 
You can use WAAnchorTag>>#document:mimeType:fileName: to render a download link.
Have a look at the code for WAUploadFunctionalTest>>#renderDownloadLinksOn: to see how it is used.
(If you look at the test in the browser, you will have to upload a file first before you will see the download links rendered)
 
Hope this helps
John
 

 
On Wed, Mar 9, 2011 at 10:07 AM, Ricardo Jacas <[hidden email]> wrote:
how can i actually do the download?  i,ve been trying for hours.... :/

2011/3/8 Ricardo Jacas <[hidden email]>:
> thx Avi, i'll give it a try :)
>
> 2011/3/8 Avi Shefi <[hidden email]>:
>> Serving them directly from a webserver can be performed in two ways:
>> 1) completely detached from Seaside, where the links are simply external.
>> 2) referenced by FileLibrary, but served through the webserver. This can be
>> done using the new X-Sendfile functionality (using the base url as
>> mentioned).
>>
>>
>> Avi.
>>
>> On Tue, Mar 8, 2011 at 10:59 PM, Robert Sirois <[hidden email]>
>> wrote:
>>>
>>> Then the web server would be serving them directly (nginx, apache, etc.),
>>> right?
>>>
>>> I'm interested in this, too. I was gonna be looking at doing something
>>> similar to Dropbox or Base Camp.
>>>
>>> RS
>>>
>>> ________________________________
>>> Date: Tue, 8 Mar 2011 22:19:53 +0200
>>> Subject: Re: [Seaside] Making a download page
>>> From: [hidden email]
>>> To: [hidden email]
>>>
>>> There are several options to this.
>>>  - Upload all files to the file library in advance, and display them to
>>> the user. The FileLibrary also provides mechanism for loading new files, so
>>> there should be no problem to update it.
>>>  - Load files from the filesystem into the filelibrary (using
>>> WAFileLibrary>>#addFile, or WAFileLibrary class >>#addFileAt: /
>>> addAllFilesIn: ).
>>>  - There's a new option on Seaside 3.0.4 which allows you to specify a
>>> configuration value for file handlers that determines the base url of a file
>>> library. This way, your absolute urls would be:
>>> <base-url>/<file-library-name>/<file-name>
>>>
>>> You can also refer to files directly on the filesystem, which doesn't
>>> require any FileLibrary support.
>>>
>>>
>>> Avi.
>>>
>>> On Tue, Mar 8, 2011 at 9:02 PM, Ricardo Jacas <[hidden email]>
>>> wrote:
>>>
>>> Hi, i'm trying to make a simple downloading function from files
>>> already in the server.
>>> I was using the book's example but i cant make it work, because the
>>> example already has the file in a variable, and i need to refer a file
>>> in the system.
>>> anyone got a simple solution?
>>>
>>> Thanks beforehand for any help on this :)
>>>
>>> --
>>> lets reign all together
>>> _______________________________________________
>>> seaside mailing list
>>> [hidden email]
>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>>
>>>
>>> _______________________________________________ seaside mailing list
>>> [hidden email]
>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>> _______________________________________________
>>> seaside mailing list
>>> [hidden email]
>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>>
>>
>>
>> _______________________________________________
>> seaside mailing list
>> [hidden email]
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>
>>
>
>
>
> --
> lets reign all together
>



--
lets reign all together
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside



--
http://john-mckeon.us

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Making a download page

AA-2
I experimented exhaustively with this just recently; it simply doesn't work when I have files stored on my OS's native filesystem.  And I MUST apologise, because I didn't get around to filing a bug report.  (Sorry!)

First of all, there's no method forURIReturnSingleMimeTypeOrDefault:, which is called by MIMEDocument class >> guessTypeFromName: url, which is in turn called when trying to determine the file MIME type.

I did my downloads like this (note: 'aFile' is a MultiByteFileStream:):

        html anchor
                callback: [ self downloadFile: aFile ];
                with: aFile localName.

downloadFile: aFile
        self requestContext respond: [ :response |
                response
                        contentType: (MIMEType forFileNameReturnSingleMimeTypeOrDefault: aFile localName);
                        attachmentWithFileName: aFile fullName;
                        headerAt: 'X-Accel-Redirect'
                        put: aFile name ]

I'm using nginx as my webserver, so the 'X-Accel-Redirect' is the equivalent for the standard 'X-SendFile' header.

Now, this worked nicely in the past, but since I've upgraded to the latest Seaside 3.0.4, I'm having some problems...  So right now I'm debugging to find out what's going on (could be a misconfigured webserver, of course).

Amir



On Wed, 9 Mar 2011 11:25:59 -0500
John McKeon <[hidden email]> wrote:

> Ricardo,
>
>  You can use WAAnchorTag>>#document:mimeType:fileName: to render a download
> link.
> Have a look at the code for WAUploadFunctionalTest>>#renderDownloadLinksOn:
> to see how it is used.
> (If you look at the test in the browser, you will have to upload a file
> first before you will see the download links rendered)
>
> Hope this helps
> John
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Making a download page

littleSmalltalker
Amir,
The path to the file should be:
(a) accessible to the image you're running, and of course allowed by its file permissions.
(b) generally an absolute path, however your nginx configuration might need a tweak to set this up. Maybe you're missing something that nginx requires? take a look: http://wiki.nginx.org/XSendfile

Additionally, I don't understand why you're passing a MultiByteFileStream if all you need is the path to the file.


Avi.

On Wed, Mar 9, 2011 at 9:41 PM, AA <[hidden email]> wrote:
I experimented exhaustively with this just recently; it simply doesn't work when I have files stored on my OS's native filesystem.  And I MUST apologise, because I didn't get around to filing a bug report.  (Sorry!)

First of all, there's no method forURIReturnSingleMimeTypeOrDefault:, which is called by MIMEDocument class >> guessTypeFromName: url, which is in turn called when trying to determine the file MIME type.

I did my downloads like this (note: 'aFile' is a MultiByteFileStream:):

       html anchor
               callback: [ self downloadFile: aFile ];
               with: aFile localName.

downloadFile: aFile
       self requestContext respond: [ :response |
               response
                       contentType: (MIMEType forFileNameReturnSingleMimeTypeOrDefault: aFile localName);
                       attachmentWithFileName: aFile fullName;
                       headerAt: 'X-Accel-Redirect'
                       put: aFile name ]

I'm using nginx as my webserver, so the 'X-Accel-Redirect' is the equivalent for the standard 'X-SendFile' header.

Now, this worked nicely in the past, but since I've upgraded to the latest Seaside 3.0.4, I'm having some problems...  So right now I'm debugging to find out what's going on (could be a misconfigured webserver, of course).

Amir



On Wed, 9 Mar 2011 11:25:59 -0500
John McKeon <[hidden email]> wrote:

> Ricardo,
>
>  You can use WAAnchorTag>>#document:mimeType:fileName: to render a download
> link.
> Have a look at the code for WAUploadFunctionalTest>>#renderDownloadLinksOn:
> to see how it is used.
> (If you look at the test in the browser, you will have to upload a file
> first before you will see the download links rendered)
>
> Hope this helps
> John
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Making a download page

rjacas
im still stuck :/ , the download works but the result is an empty file
with the right name.. i give my code below:

        self requestContext
                respond: [ :response |
                        response
                                contentType: (MIMEType forFileNameReturnSingleMimeTypeOrDefault:
file fileName);
                                attachmentWithFileName: file fileName ]

where file is an url


2011/3/10 Avi Shefi <[hidden email]>:

> Amir,
> The path to the file should be:
> (a) accessible to the image you're running, and of course allowed by its
> file permissions.
> (b) generally an absolute path, however your nginx configuration might need
> a tweak to set this up. Maybe you're missing something that nginx requires?
> take a look: http://wiki.nginx.org/XSendfile
>
> Additionally, I don't understand why you're passing a MultiByteFileStream if
> all you need is the path to the file.
>
>
> Avi.
>
> On Wed, Mar 9, 2011 at 9:41 PM, AA <[hidden email]> wrote:
>>
>> I experimented exhaustively with this just recently; it simply doesn't
>> work when I have files stored on my OS's native filesystem.  And I MUST
>> apologise, because I didn't get around to filing a bug report.  (Sorry!)
>>
>> First of all, there's no method forURIReturnSingleMimeTypeOrDefault:,
>> which is called by MIMEDocument class >> guessTypeFromName: url, which is in
>> turn called when trying to determine the file MIME type.
>>
>> I did my downloads like this (note: 'aFile' is a MultiByteFileStream:):
>>
>>        html anchor
>>                callback: [ self downloadFile: aFile ];
>>                with: aFile localName.
>>
>> downloadFile: aFile
>>        self requestContext respond: [ :response |
>>                response
>>                        contentType: (MIMEType
>> forFileNameReturnSingleMimeTypeOrDefault: aFile localName);
>>                        attachmentWithFileName: aFile fullName;
>>                        headerAt: 'X-Accel-Redirect'
>>                        put: aFile name ]
>>
>> I'm using nginx as my webserver, so the 'X-Accel-Redirect' is the
>> equivalent for the standard 'X-SendFile' header.
>>
>> Now, this worked nicely in the past, but since I've upgraded to the latest
>> Seaside 3.0.4, I'm having some problems...  So right now I'm debugging to
>> find out what's going on (could be a misconfigured webserver, of course).
>>
>> Amir
>>
>>
>>
>> On Wed, 9 Mar 2011 11:25:59 -0500
>> John McKeon <[hidden email]> wrote:
>>
>> > Ricardo,
>> >
>> >  You can use WAAnchorTag>>#document:mimeType:fileName: to render a
>> > download
>> > link.
>> > Have a look at the code for
>> > WAUploadFunctionalTest>>#renderDownloadLinksOn:
>> > to see how it is used.
>> > (If you look at the test in the browser, you will have to upload a file
>> > first before you will see the download links rendered)
>> >
>> > Hope this helps
>> > John
>> _______________________________________________
>> seaside mailing list
>> [hidden email]
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>



--
lets reign all together
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Making a download page

AA-2
In reply to this post by littleSmalltalker
Hi Avi

The path is accessible, and absolute.  I studied the nginx wiki very carefully, too.  It's an odd problem, because it WAS working properly in the past...

I only noted the MultiByteFileStream because that's the file object when it's saved to the native filesystem; it's different from uploading a file to the image (which is what WAUploadFunctionalTest does).


On Thu, 10 Mar 2011 10:46:33 +0200
Avi Shefi <[hidden email]> wrote:

> Amir,
> The path to the file should be:
> (a) accessible to the image you're running, and of course allowed by its
> file permissions.
> (b) generally an absolute path, however your nginx configuration might need
> a tweak to set this up. Maybe you're missing something that nginx requires?
> take a look: http://wiki.nginx.org/XSendfile
>
> Additionally, I don't understand why you're passing a MultiByteFileStream if
> all you need is the path to the file.
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Making a download page

rjacas
i just dropped my code and used the function John said, but as AA says
the file is represented as a MultiByteFileStream not a WAFile...any
thoughts on how to work with that? or even make it a WAFile?



2011/3/10 AA <[hidden email]>:

> Hi Avi
>
> The path is accessible, and absolute.  I studied the nginx wiki very carefully, too.  It's an odd problem, because it WAS working properly in the past...
>
> I only noted the MultiByteFileStream because that's the file object when it's saved to the native filesystem; it's different from uploading a file to the image (which is what WAUploadFunctionalTest does).
>
>
> On Thu, 10 Mar 2011 10:46:33 +0200
> Avi Shefi <[hidden email]> wrote:
>
>> Amir,
>> The path to the file should be:
>> (a) accessible to the image you're running, and of course allowed by its
>> file permissions.
>> (b) generally an absolute path, however your nginx configuration might need
>> a tweak to set this up. Maybe you're missing something that nginx requires?
>> take a look: http://wiki.nginx.org/XSendfile
>>
>> Additionally, I don't understand why you're passing a MultiByteFileStream if
>> all you need is the path to the file.
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>



--
lets reign all together
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Making a download page

littleSmalltalker
As for the detection of mime types, why not use: WAFileLibrary mimetypeFor: (aFilename copyAfterLast: $.)
The bug that
MIMEDocument class>>#forURIReturnSingleMimeTypeOrDefault: doesn't exist is associated with Pharo, not with Seaside (the class is in a Pharo package named Network-MIME). You're invited to file a bug in the Pharo issues list: http://code.google.com/p/pharo/issues/list

As for the MultiByteFileStream - I looked around and I *think* WAAnchorTag can accept a MultiByteFileStream, which is later on converted to a WAMimeDocument. Have you given this a try?
In general, if you somehow managed to get a MultiByteFileStream, it means that you should also hold the path to that file. So why not pass this path to the nginx-related X-Sendfile headers?


Avi.

On Thu, Mar 10, 2011 at 7:29 PM, Ricardo Jacas <[hidden email]> wrote:
i just dropped my code and used the function John said, but as AA says
the file is represented as a MultiByteFileStream not a WAFile...any
thoughts on how to work with that? or even make it a WAFile?



2011/3/10 AA <[hidden email]>:
> Hi Avi
>
> The path is accessible, and absolute.  I studied the nginx wiki very carefully, too.  It's an odd problem, because it WAS working properly in the past...
>
> I only noted the MultiByteFileStream because that's the file object when it's saved to the native filesystem; it's different from uploading a file to the image (which is what WAUploadFunctionalTest does).
>
>
> On Thu, 10 Mar 2011 10:46:33 +0200
> Avi Shefi <[hidden email]> wrote:
>
>> Amir,
>> The path to the file should be:
>> (a) accessible to the image you're running, and of course allowed by its
>> file permissions.
>> (b) generally an absolute path, however your nginx configuration might need
>> a tweak to set this up. Maybe you're missing something that nginx requires?
>> take a look: http://wiki.nginx.org/XSendfile
>>
>> Additionally, I don't understand why you're passing a MultiByteFileStream if
>> all you need is the path to the file.
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>



--
lets reign all together
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Making a download page

AA-2
Hi Avi

WAFileLibrary mimetypeFor: is a better method, thanks!  WAAnchorTag >> document:mimeType:fileName: doesn't seem to work with MultiByteFileStream; I get errors.

In any case, with the current code, the response headers appear to be correct, so it probably indicates a problem with nginx.  Just for reference, this is what I get from 'Transcript show: response headers':

        a WAHeaderFields('Content-Type'->'image/png' 'Content-Disposition'->'attachment; filename="/downloads/test.png"' 'X-Accel-Redirect'->'/downloads/test.png')

I'll keep digging, just want to verify that I'm doing things properly on the Seaside end!

Thanks,

Amir



On Thu, 10 Mar 2011 21:53:13 +0200
Avi Shefi <[hidden email]> wrote:

> As for the detection of mime types, why not use: WAFileLibrary mimetypeFor:
> (aFilename copyAfterLast: $.)
> The bug that MIMEDocument class>>#forURIReturnSingleMimeTypeOrDefault:
> doesn't exist is associated with Pharo, not with Seaside (the class is in a
> Pharo package named Network-MIME). You're invited to file a bug in the Pharo
> issues list: http://code.google.com/p/pharo/issues/list
>
> As for the MultiByteFileStream - I looked around and I *think* WAAnchorTag
> can accept a MultiByteFileStream, which is later on converted to a
> WAMimeDocument. Have you given this a try?
> In general, if you somehow managed to get a MultiByteFileStream, it means
> that you should also hold the path to that file. So why not pass this path
> to the nginx-related X-Sendfile headers?
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Making a download page

littleSmalltalker
Amir,
The headers look fine. I'm interested in your code, specifically from where you get a MultiByteFileStream.
Could you elaborate please? maybe supply your code?


Cheers,
Avi.

On Fri, Mar 11, 2011 at 10:19 AM, AA <[hidden email]> wrote:
Hi Avi

WAFileLibrary mimetypeFor: is a better method, thanks!  WAAnchorTag >> document:mimeType:fileName: doesn't seem to work with MultiByteFileStream; I get errors.

In any case, with the current code, the response headers appear to be correct, so it probably indicates a problem with nginx.  Just for reference, this is what I get from 'Transcript show: response headers':

       a WAHeaderFields('Content-Type'->'image/png' 'Content-Disposition'->'attachment; filename="/downloads/test.png"' 'X-Accel-Redirect'->'/downloads/test.png')

I'll keep digging, just want to verify that I'm doing things properly on the Seaside end!

Thanks,

Amir



On Thu, 10 Mar 2011 21:53:13 +0200
Avi Shefi <[hidden email]> wrote:

> As for the detection of mime types, why not use: WAFileLibrary mimetypeFor:
> (aFilename copyAfterLast: $.)
> The bug that MIMEDocument class>>#forURIReturnSingleMimeTypeOrDefault:
> doesn't exist is associated with Pharo, not with Seaside (the class is in a
> Pharo package named Network-MIME). You're invited to file a bug in the Pharo
> issues list: http://code.google.com/p/pharo/issues/list
>
> As for the MultiByteFileStream - I looked around and I *think* WAAnchorTag
> can accept a MultiByteFileStream, which is later on converted to a
> WAMimeDocument. Have you given this a try?
> In general, if you somehow managed to get a MultiByteFileStream, it means
> that you should also hold the path to that file. So why not pass this path
> to the nginx-related X-Sendfile headers?
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Making a download page

AA-2
Thanks for looking at the headers.  Here's the rest of my code:

renderUploadOn: html
        html form multipart; with: [
                html fileUpload callback: [ :f | self uploadFile: f ].
                html submitButton text: 'Load' ]

uploadFile: aFile
        file := (FileDirectory default directoryNamed: self filePath) assureExistence;
                forceNewFileNamed: aFile fileName.
        [ file binary; nextPutAll: aFile contents ]
                ensure: [ file close ].
        ^ file


Amir


On Fri, 11 Mar 2011 11:11:45 +0200
Avi Shefi <[hidden email]> wrote:

> Amir,
> The headers look fine. I'm interested in your code, specifically from where
> you get a MultiByteFileStream.
> Could you elaborate please? maybe supply your code?
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Making a download page

littleSmalltalker
Amir,
Your code is fine, and works OK. The only thing that's wrong is that it uses contentType:attachementWithFileName , whereas X-Accel-Redirect doesn't require these headers. Using these headers will confuse browsers into thinking that you're actually trying to download a file (without X-Sendfile redirection). This is why you get a file with 0 bytes - there's no file contents in the transport.

You should use only contentType and X-Accel-Redirect to specify your file.


Cheers,
Avi.

On Fri, Mar 11, 2011 at 12:12 PM, AA <[hidden email]> wrote:
Thanks for looking at the headers.  Here's the rest of my code:

renderUploadOn: html
       html form multipart; with: [
               html fileUpload callback: [ :f | self uploadFile: f ].
               html submitButton text: 'Load' ]

uploadFile: aFile
       file := (FileDirectory default directoryNamed: self filePath) assureExistence;
               forceNewFileNamed: aFile fileName.
       [ file binary; nextPutAll: aFile contents ]
               ensure: [ file close ].
       ^ file


Amir


On Fri, 11 Mar 2011 11:11:45 +0200
Avi Shefi <[hidden email]> wrote:

> Amir,
> The headers look fine. I'm interested in your code, specifically from where
> you get a MultiByteFileStream.
> Could you elaborate please? maybe supply your code?
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Making a download page

AA-2
Hi Avi, Ricardo

I found my error!  I'd set the file download directory to be in my home directory: '/home/me/downloads'.  But, of course, this absolute path isn't recognised as a valid URL by nginx, so (duh!) that's why it wouldn't work.  After moving '/downloads' to the root directory (and changing the permissions), it works fine.

I've also found it necessary to use 'attachmentWithFileName:', otherwise the web server assumes the content-disposition to be 'inline' rather than 'attached', and displays the file instead of saving it.

Avi, thanks for all your help!  Ricardo, have you managed to get your downloads working yet?

Amir


On Sun, 13 Mar 2011 10:05:40 +0200
Avi Shefi <[hidden email]> wrote:

> Amir,
> Your code is fine, and works OK. The only thing that's wrong is that it uses
> contentType:attachementWithFileName , whereas X-Accel-Redirect doesn't
> require these headers. Using these headers will confuse browsers into
> thinking that you're actually trying to download a file (without X-Sendfile
> redirection). This is why you get a file with 0 bytes - there's no file
> contents in the transport.
>
> You should use only contentType and X-Accel-Redirect to specify your file.
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Making a download page

rjacas
no, but i'm not trying anymore, thanks very much for the advice anyway

2011/3/20 AA <[hidden email]>
Hi Avi, Ricardo

I found my error!  I'd set the file download directory to be in my home directory: '/home/me/downloads'.  But, of course, this absolute path isn't recognised as a valid URL by nginx, so (duh!) that's why it wouldn't work.  After moving '/downloads' to the root directory (and changing the permissions), it works fine.

I've also found it necessary to use 'attachmentWithFileName:', otherwise the web server assumes the content-disposition to be 'inline' rather than 'attached', and displays the file instead of saving it.

Avi, thanks for all your help!  Ricardo, have you managed to get your downloads working yet?

Amir


On Sun, 13 Mar 2011 10:05:40 +0200
Avi Shefi <[hidden email]> wrote:

> Amir,
> Your code is fine, and works OK. The only thing that's wrong is that it uses
> contentType:attachementWithFileName , whereas X-Accel-Redirect doesn't
> require these headers. Using these headers will confuse browsers into
> thinking that you're actually trying to download a file (without X-Sendfile
> redirection). This is why you get a file with 0 bytes - there's no file
> contents in the transport.
>
> You should use only contentType and X-Accel-Redirect to specify your file.
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside



--
lets reign all together

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside