Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
7505e508
Commit
7505e508
authored
Dec 16, 2005
by
Sidnei da Silva
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Collector #1976: FTP STOR command would load the file being
uploaded in memory. Changed to use a TemporaryFile.
parent
8f4563e1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
21 deletions
+31
-21
doc/CHANGES.txt
doc/CHANGES.txt
+3
-0
lib/python/ZServer/FTPRequest.py
lib/python/ZServer/FTPRequest.py
+11
-7
lib/python/ZServer/FTPServer.py
lib/python/ZServer/FTPServer.py
+17
-14
No files found.
doc/CHANGES.txt
View file @
7505e508
...
...
@@ -120,6 +120,9 @@ Zope Changes
Bugs Fixed
- Collector #1976: FTP STOR command would load the file being
uploaded in memory. Changed to use a TemporaryFile.
- OFS ObjectManager: Fixed list_imports() to tolerate missing
import directories.
...
...
lib/python/ZServer/FTPRequest.py
View file @
7505e508
...
...
@@ -27,7 +27,7 @@ import re
class
FTPRequest
(
HTTPRequest
):
def
__init__
(
self
,
path
,
command
,
channel
,
response
,
stdin
=
None
,
environ
=
None
,
globbing
=
None
,
recursive
=
0
):
environ
=
None
,
globbing
=
None
,
recursive
=
0
,
size
=
None
):
# we need to store the globbing information to pass it
# to the ZPublisher and the manage_FTPlist function
...
...
@@ -35,9 +35,12 @@ class FTPRequest(HTTPRequest):
self
.
globbing
=
globbing
self
.
recursive
=
recursive
if
stdin
is
None
:
stdin
=
StringIO
()
if
stdin
is
None
:
size
=
0
stdin
=
StringIO
()
if
environ
is
None
:
environ
=
self
.
_get_env
(
path
,
command
,
channel
,
stdin
)
environ
=
self
.
_get_env
(
path
,
command
,
channel
,
stdin
,
size
)
self
.
_orig_env
=
environ
HTTPRequest
.
__init__
(
self
,
stdin
,
environ
,
response
,
clean
=
1
)
...
...
@@ -61,7 +64,7 @@ class FTPRequest(HTTPRequest):
)
return
r
def
_get_env
(
self
,
path
,
command
,
channel
,
stdin
):
def
_get_env
(
self
,
path
,
command
,
channel
,
stdin
,
size
):
"Returns a CGI style environment"
env
=
{}
env
[
'SCRIPT_NAME'
]
=
'/%s'
%
channel
.
module
...
...
@@ -109,9 +112,10 @@ class FTPRequest(HTTPRequest):
env
[
'QUERY_STRING'
]
=
'id=%s&new_id=%s'
%
(
args
[
0
],
args
[
1
])
elif
command
==
'STOR'
:
env
[
'PATH_INFO'
]
=
self
.
_join_paths
(
channel
.
path
,
path
)
env
[
'REQUEST_METHOD'
]
=
'PUT'
env
[
'CONTENT_LENGTH'
]
=
len
(
stdin
.
getvalue
())
env
[
'PATH_INFO'
]
=
self
.
_join_paths
(
channel
.
path
,
path
)
env
[
'REQUEST_METHOD'
]
=
'PUT'
env
[
'CONTENT_LENGTH'
]
=
long
(
size
)
else
:
env
[
'PATH_INFO'
]
=
self
.
_join_paths
(
channel
.
path
,
path
,
command
)
...
...
lib/python/ZServer/FTPServer.py
View file @
7505e508
...
...
@@ -352,7 +352,7 @@ class zope_ftp_channel(ftp_channel):
# Right now we are limited in the errors we can issue, since
# we agree to accept the file before checking authorization
fd
=
ContentReceiver
(
self
.
stor_callback
,
line
[
1
])
fd
=
ContentReceiver
(
self
.
stor_callback
,
line
[
1
])
self
.
respond
(
'150 Opening %s connection for %s'
%
(
self
.
type_map
[
self
.
current_mode
],
...
...
@@ -361,14 +361,15 @@ class zope_ftp_channel(ftp_channel):
)
self
.
make_recv_channel
(
fd
)
def
stor_callback
(
self
,
path
,
data
):
def
stor_callback
(
self
,
path
,
data
,
size
):
'callback to do the STOR, after we have the input'
response
=
make_response
(
self
,
self
.
stor_completion
)
request
=
FTPRequest
(
path
,
'STOR'
,
self
,
response
,
stdin
=
data
)
handle
(
self
.
module
,
request
,
response
)
response
=
make_response
(
self
,
self
.
stor_completion
)
request
=
FTPRequest
(
path
,
'STOR'
,
self
,
response
,
stdin
=
data
,
size
=
size
)
handle
(
self
.
module
,
request
,
response
)
def
stor_completion
(
self
,
response
):
status
=
response
.
getStatus
()
def
stor_completion
(
self
,
response
):
status
=
response
.
getStatus
()
if
status
in
(
200
,
201
,
204
,
302
):
self
.
client_dc
.
channel
.
respond
(
'226 Transfer complete.'
)
...
...
@@ -559,19 +560,21 @@ class ContentReceiver:
"Write-only file object used to receive data from FTP"
def
__init__
(
self
,
callback
,
*
args
):
self
.
data
=
StringIO
()
self
.
callback
=
callback
self
.
args
=
args
from
tempfile
import
TemporaryFile
self
.
data
=
TemporaryFile
(
'w+b'
)
self
.
callback
=
callback
self
.
args
=
args
def
write
(
self
,
data
):
self
.
data
.
write
(
data
)
def
close
(
self
):
size
=
self
.
data
.
tell
()
self
.
data
.
seek
(
0
)
args
=
self
.
args
+
(
self
.
data
,
)
c
=
self
.
callback
self
.
callback
=
None
self
.
args
=
None
args
=
self
.
args
+
(
self
.
data
,
size
)
c
=
self
.
callback
self
.
callback
=
None
self
.
args
=
None
c
(
*
args
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment