Fixed to make progress bar and download link work properly in IE 6 and 7.
This commit is contained in:
parent
b543121767
commit
b80ad248f9
|
@ -147,6 +147,8 @@ class FieldStorage( cherrypy._cpcgifs.FieldStorage ):
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise Upload_error( "The file_id is invalid." )
|
raise Upload_error( "The file_id is invalid." )
|
||||||
|
|
||||||
|
self.filename = self.filename.split( "/" )[ -1 ].split( "\\" )[ -1 ].strip()
|
||||||
|
|
||||||
if not self.filename:
|
if not self.filename:
|
||||||
raise Upload_error( "Please provide a filename." )
|
raise Upload_error( "Please provide a filename." )
|
||||||
|
|
||||||
|
@ -164,7 +166,7 @@ class FieldStorage( cherrypy._cpcgifs.FieldStorage ):
|
||||||
if existing_file:
|
if existing_file:
|
||||||
existing_file.close()
|
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()
|
current_uploads_lock.acquire()
|
||||||
try:
|
try:
|
||||||
|
@ -232,9 +234,9 @@ class Files( object ):
|
||||||
|
|
||||||
db_file = self.__database.load( File, file_id )
|
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-Disposition" ] = u"attachment; filename=%s" % db_file.filename
|
||||||
cherrypy.response.headerMap[ u"Content-Length" ] = db_file.size_bytes
|
cherrypy.response.headerMap[ u"Content-Length" ] = db_file.size_bytes
|
||||||
cherrypy.response.headerMap[ u"Content-Type" ] = db_file.content_type
|
|
||||||
|
|
||||||
def stream():
|
def stream():
|
||||||
CHUNK_SIZE = 8192
|
CHUNK_SIZE = 8192
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
from Persistent import Persistent, quote
|
from Persistent import Persistent, quote
|
||||||
from psycopg2 import Binary
|
|
||||||
from StringIO import StringIO
|
|
||||||
|
|
||||||
|
|
||||||
class File( Persistent ):
|
class File( Persistent ):
|
||||||
|
|
|
@ -2260,6 +2260,17 @@ function Upload_pulldown( wiki, notebook_id, invoker, editor ) {
|
||||||
connect( this.iframe, "onload", function ( event ) { self.init_frame(); } );
|
connect( this.iframe, "onload", function ( event ) { self.init_frame(); } );
|
||||||
|
|
||||||
appendChildNodes( this.div, this.iframe );
|
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; };
|
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;
|
this.file_id = file_id;
|
||||||
|
|
||||||
// make the upload iframe invisible but still present so that the upload continues
|
// make the upload iframe invisible but still present so that the upload continues
|
||||||
addElementClass( this.iframe, "invisible" );
|
|
||||||
setElementDimensions( this.iframe, { "h": "0" } );
|
setElementDimensions( this.iframe, { "h": "0" } );
|
||||||
|
|
||||||
// get the basename of the file
|
// get the basename of the file
|
||||||
|
@ -2295,24 +2305,15 @@ Upload_pulldown.prototype.upload_started = function ( file_id, filename ) {
|
||||||
if ( link_title( this.link ) == "" )
|
if ( link_title( this.link ) == "" )
|
||||||
replaceChildNodes( this.link, this.editor.document.createTextNode( filename ) );
|
replaceChildNodes( this.link, this.editor.document.createTextNode( filename ) );
|
||||||
|
|
||||||
// FIXME: this call might occur before upload() is even called
|
removeElementClass( this.progress_iframe, "undisplayed" );
|
||||||
var progress_iframe = createDOM( "iframe", {
|
frames[ "progress_frame" ].location.href = "/files/progress?file_id=" + file_id + "&filename=" + escape( filename );
|
||||||
"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 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Upload_pulldown.prototype.upload_complete = function () {
|
Upload_pulldown.prototype.upload_complete = function () {
|
||||||
// now that the upload is done, the file link should point to the uploaded file
|
// 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
|
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 );
|
new File_link_pulldown( this.wiki, this.notebook_id, this.invoker, this.editor, this.link );
|
||||||
this.shutdown();
|
this.shutdown();
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue