1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-19 01:44:13 +00:00

Merge pull request #732 from haiwen/op-copy

Op copy
This commit is contained in:
xiez
2015-07-23 10:41:41 +08:00
2 changed files with 18 additions and 2 deletions

View File

@@ -1514,7 +1514,7 @@ class OpCopyView(APIView):
return api_error(status.HTTP_403_FORBIDDEN,
'You do not have permission to copy file.')
parent_dir = request.POST.get('p', '/')
parent_dir = request.GET.get('p', '/')
dst_repo = request.POST.get('dst_repo', None)
dst_dir = request.POST.get('dst_dir', None)
file_names = request.POST.get("file_names", None)

View File

@@ -5,7 +5,7 @@ Test file/dir operations.
import random
import re
from urllib import urlencode, quote
from urllib import urlencode, quote, quote
from tests.common.utils import randstring, urljoin
from tests.api.urls import DEFAULT_REPO_URL, REPOS_URL
@@ -54,6 +54,22 @@ class FilesApiTest(ApiTestBase):
res = self.post(fopurl, data=data)
self.assertEqual(res.text, '"success"')
# create tmp file in sub folder(dpath)
tmp_file = 'tmp_file.txt'
furl = repo.get_filepath_url(dpath + '/' + tmp_file)
data = {'operation': 'create'}
res = self.post(furl, data=data, expected=201)
# copy tmp file(in dpath) to dst dir
fopurl = urljoin(repo.repo_url, 'fileops/copy/') + '?p=' + quote(dpath)
data = {
'file_names': tmp_file,
'dst_repo': repo.repo_id,
'dst_dir': dpath,
}
res = self.post(fopurl, data=data)
self.assertEqual(res.text, '"success"')
def test_download_file(self):
with self.get_tmp_repo() as repo:
fname, furl = self.create_file(repo)