remove debug
This commit is contained in:
parent
d6b5fa6993
commit
14315455da
1 changed files with 4 additions and 6 deletions
|
@ -13,15 +13,13 @@ class ChunkForm(forms.Form):
|
|||
offset = forms.IntegerField(required=False)
|
||||
done = forms.IntegerField(required=False)
|
||||
|
||||
def save_chunk(self, file, chunk, offset, name, done_cb=None):
|
||||
print 'file', file
|
||||
print 'chunk', chunk
|
||||
def save_chunk(obj, file, chunk, offset, name, done_cb=None):
|
||||
if not file:
|
||||
file.name = name
|
||||
ox.makedirs(os.path.dirname(file.path))
|
||||
with open(file.path, 'w') as f:
|
||||
f.write(chunk.read())
|
||||
self.save()
|
||||
obj.save()
|
||||
else:
|
||||
path = file.path
|
||||
size = file.size
|
||||
|
@ -34,14 +32,14 @@ def save_chunk(self, file, chunk, offset, name, done_cb=None):
|
|||
f.write(chunk.read())
|
||||
return done_cb() if done_cb else True, file.size
|
||||
|
||||
def process_chunk(request, _save_chunk):
|
||||
def process_chunk(request, save_chunk):
|
||||
response = {
|
||||
'result': 1,
|
||||
}
|
||||
form = ChunkForm(request.POST, request.FILES)
|
||||
if form.is_valid():
|
||||
d = form.cleaned_data
|
||||
ok, _offset = _save_chunk(d['chunk'], d['offset'], d['done'])
|
||||
ok, _offset = save_chunk(d['chunk'], d['offset'], d['done'])
|
||||
response['offset'] = _offset
|
||||
response['result'] = 1 if ok else -1
|
||||
if d['done']:
|
||||
|
|
Loading…
Reference in a new issue