Commit 9d90d5a3 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Merge branch '347483-corpus-upload-zip-fix' into 'master'

Corpus Management Fix corrupt file upload (unreleased feature)

See merge request gitlab-org/gitlab!76870
parents 71becb2a 3a46ff4e
......@@ -19,13 +19,7 @@ export function publishPackage(
status: 'default',
};
const formData = new FormData();
formData.append('file', files[0]);
return axios.put(url, formData, {
headers: {
'Content-Type': 'multipart/form-data',
},
return axios.put(url, files[0], {
params: Object.assign(defaults, options),
...axiosOptions,
});
......
......@@ -73,7 +73,7 @@ export default {
cache.writeQuery({ query: getCorpusesQuery, data: targetData, variables: { projectPath } });
publishPackage(
{ projectPath, name, version: 0, fileName: name, files },
{ projectPath, name, version: 0, fileName: `${name}.zip`, files },
{ status: 'hidden', select: 'package_file' },
{ onUploadProgress, cancelToken: source.token },
)
......
......@@ -38,12 +38,17 @@ describe('Api', () => {
mock.onPut(expectedUrl).replyOnce(httpStatus.OK, apiResponse);
return publishPackage(
{ projectPath, name, version: 0, fileName: name, files: [{}] },
{
projectPath,
name,
version: 0,
fileName: name,
files: [new File(['zip contents'], 'bar.zip')],
},
{ status: 'hidden', select: 'package_file' },
).then(({ data }) => {
expect(data).toEqual(apiResponse);
expect(axios.put).toHaveBeenCalledWith(expectedUrl, expect.any(FormData), {
headers: { 'Content-Type': 'multipart/form-data' },
expect(axios.put).toHaveBeenCalledWith(expectedUrl, expect.any(File), {
params: { select: 'package_file', status: 'hidden' },
});
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment