witten
/
luminotes
Archived
1
0
Fork 0

Fixed to make progress bar and download link work properly in IE 6 and 7.

This commit is contained in:
Dan Helfman 2008-02-18 23:44:17 +00:00
parent b543121767
commit b80ad248f9
3 changed files with 18 additions and 17 deletions

View File

@ -147,6 +147,8 @@ class FieldStorage( cherrypy._cpcgifs.FieldStorage ):
except ValueError:
raise Upload_error( "The file_id is invalid." )
self.filename = self.filename.split( "/" )[ -1 ].split( "\\" )[ -1 ].strip()
if not self.filename:
raise Upload_error( "Please provide a filename." )
@ -164,7 +166,7 @@ class FieldStorage( cherrypy._cpcgifs.FieldStorage ):
if existing_file:
existing_file.close()
upload_file = Upload_file( file_id, self.filename.strip(), content_length )
upload_file = Upload_file( file_id, self.filename, content_length )
current_uploads_lock.acquire()
try:
@ -232,9 +234,9 @@ class Files( object ):
db_file = self.__database.load( File, file_id )
cherrypy.response.headerMap[ u"Content-Type" ] = db_file.content_type
cherrypy.response.headerMap[ u"Content-Disposition" ] = u"attachment; filename=%s" % db_file.filename
cherrypy.response.headerMap[ u"Content-Length" ] = db_file.size_bytes
cherrypy.response.headerMap[ u"Content-Type" ] = db_file.content_type
def stream():
CHUNK_SIZE = 8192

View File

@ -1,6 +1,4 @@
from Persistent import Persistent, quote
from psycopg2 import Binary
from StringIO import StringIO
class File( Persistent ):

View File

@ -2260,6 +2260,17 @@ function Upload_pulldown( wiki, notebook_id, invoker, editor ) {
connect( this.iframe, "onload", function ( event ) { self.init_frame(); } );
appendChildNodes( this.div, this.iframe );
this.progress_iframe = createDOM( "iframe", {
"frameBorder": "0",
"scrolling": "no",
"id": "progress_frame",
"name": "progress_frame",
"class": "upload_frame"
} );
addElementClass( this.progress_iframe, "undisplayed" );
appendChildNodes( this.div, this.progress_iframe );
}
Upload_pulldown.prototype = new function () { this.prototype = Pulldown.prototype; };
@ -2282,7 +2293,6 @@ Upload_pulldown.prototype.upload_started = function ( file_id, filename ) {
this.file_id = file_id;
// make the upload iframe invisible but still present so that the upload continues
addElementClass( this.iframe, "invisible" );
setElementDimensions( this.iframe, { "h": "0" } );
// get the basename of the file
@ -2295,24 +2305,15 @@ Upload_pulldown.prototype.upload_started = function ( file_id, filename ) {
if ( link_title( this.link ) == "" )
replaceChildNodes( this.link, this.editor.document.createTextNode( filename ) );
// FIXME: this call might occur before upload() is even called
var progress_iframe = createDOM( "iframe", {
"src": "/files/progress?file_id=" + file_id + "&filename=" + escape( filename ),
"frameBorder": "0",
"scrolling": "no",
"id": "progress_frame",
"name": "progress_frame",
"class": "upload_frame"
} );
appendChildNodes( this.div, progress_iframe );
removeElementClass( this.progress_iframe, "undisplayed" );
frames[ "progress_frame" ].location.href = "/files/progress?file_id=" + file_id + "&filename=" + escape( filename );
}
Upload_pulldown.prototype.upload_complete = function () {
// now that the upload is done, the file link should point to the uploaded file
// FIXME: this may kill the text cursor in IE 7
this.link.href = "/files/download?file_id=" + this.file_id
// FIXME: the upload pulldown is sometimes being closed here before the upload is complete, thereby truncating the upload
new File_link_pulldown( this.wiki, this.notebook_id, this.invoker, this.editor, this.link );
this.shutdown();
}