Welcome to mirror list, hosted at ThFree Co, Russian Federation.

packages_api.js « api « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 47f51c7e80e9791042b864bad142fd73c3c04dba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import axios from '../lib/utils/axios_utils';
import { buildApiUrl } from './api_utils';

const PUBLISH_PACKAGE_PATH =
  '/api/:version/projects/:id/packages/generic/:package_name/:package_version/:file_name';

export function publishPackage(
  { projectPath, name, version, fileName, files },
  options,
  axiosOptions = {},
) {
  const url = buildApiUrl(PUBLISH_PACKAGE_PATH)
    .replace(':id', encodeURIComponent(projectPath))
    .replace(':package_name', name)
    .replace(':package_version', version)
    .replace(':file_name', fileName);

  const defaults = {
    status: 'default',
  };

  const formData = new FormData();
  formData.append('file', files[0]);

  return axios.put(url, formData, {
    headers: {
      'Content-Type': 'multipart/form-data',
    },
    params: Object.assign(defaults, options),
    ...axiosOptions,
  });
}