Edit in GitHubLog an issue

Files

Use the files resource to manage all artifacts that you upload:

  • Magento 2 ZIP files (.zip)
  • PDF documents for user guides, installation guides, and reference manuals
  • Product icons
  • Image files for galleries
  • Image files for your personal and company profile

Each file upload receives a unique ID. You must associate these IDs with your submission later using the packages API.

You can associate a file with multiple products. This allows for asset sharing across different packages. For example, you can share an image file for a gallery with different packages by associating it with the same file upload ID.

All files that you upload are inspected for malware. We only accept packages for further review if all associated files have passed the malware inspection.

File uploads#

Use this API to upload files, retrieve file upload status, and remove files.

Copied to your clipboard
1GET /rest/v1/files/uploads/:file_upload_id
2POST /rest/v1/files/uploads

Get a file upload#

Use the upload ID to retrieve details about a file upload.

Copied to your clipboard
GET /rest/v1/files/uploads/:file_upload_id

Parameters:

FieldTypeDescription
file_upload_idURL elementThe file_upload_id string that was returned when uploading or listing the file.
offsetintIndex of the first element to return in the response. Used for pagination.
limitintMaximum number of list items to return in the response. Used for pagination.

Sorting and filtering parameters are currently not available for this endpoint.

If the file_upload_id parameter is specified, a single file record will be returned. If it is omitted, then a batch response will be returned: an array of records for all files uploaded by the current user.

Copied to your clipboard
1curl -X GET \
2 -H 'Authorization: Bearer baGXoStRuR9VCDFQGZNzgNqbqu5WUwlr.cAxZJ9m22Le7' \
3 https://developer-stg-api.magento.com/rest/v1/files/uploads/5c129cd41ba478.65767699.1

Response field details:

FieldTypeDescription
file_upload_idstringUnique identifier for the file.
filenamestringThe name of the file sent in the request.
content_typestringThe mime-type for which the file was uploaded.
sizeintegerThe size of the file in bytes.
malware_statusstringMalware check result for this file. Valid values include: pass, fail, in-progress.
file_hashstringHash of the file; currently md5. Only set if malware_status is pass.
urlstringThe URL from which the file may be downloaded, if applicable.
submission_idsarrayThe list of package submissions associated with this file, if any.

The order of fields may differ, and additional fields may also be returned.

Upload files#

Upload files in bulk using the multipart/form-data encoding type. With this approach, binary files can be uploaded without the need for additional encoding, which could otherwise result in an increase in overall upload size.

Copied to your clipboard
POST /rest/v1/files/uploads

A sample request body of mime type, multipart/form-data with a boundary string of UNIQUE_BOUNDARY_TOKEN is shown below:

Copied to your clipboard
Content-Type: multipart/form-data; boundary=UNIQUE_BOUNDARY_TOKEN

For more info on multipart/form-data requests, see the IETF specification

Copied to your clipboard
1--UNIQUE_BOUNDARY_TOKEN
2Content-Disposition: form-data; name="file[]"; filename="acme_one-click-checkout.zip"
3Content-Type: application/zip
4
5<zip file content here.....>
6
7--UNIQUE_BOUNDARY_TOKEN
8Content-Disposition: form-data; name="file[]"; filename="icon.png"
9Content-Type: image/png
10
11<image file content here.....>
12
13--UNIQUE_BOUNDARY_TOKEN
14Content-Disposition: form-data; name="file[]"; filename="acme-logo.png"
15Content-Type: image/png
16
17<image file content here.....>
18
19--UNIQUE_BOUNDARY_TOKEN
20Content-Disposition: form-data; name="file[]"; filename="user.pdf"
21Content-Type: application/pdf
22
23<pdf file content here....>
24
25--UNIQUE_BOUNDARY_TOKEN--
  • Each part has a header and body.
  • The body of each part is the full contents of the raw file.
  • The header has the following required elements:
ElementTypeDescription
Content-DispositionstringMUST be form-data
namestringMUST be file[] for all parts.
filenamestringShould be the original name of the file.
Content-TypestringShould be the correct mime-type for the file.

Recognized Content-Types

File TypeRecognized Content-TypeUsage
pngimage/pngavatar, gallery
jpg / jpegimage/jpegavatar, gallery
gifimage/gifavatar
pdfapplication/pdfdocument
zipapplication/zippackage
zipapplication/x-zip-compressedpackage
zipapplication/octet-streampackage

If the request body given above was saved into a temporary file at /tmp/files-payload, you may use it in your POST request to upload the files:

Copied to your clipboard
1curl -X POST \
2 -H 'Authorization: Bearer baGXoStRuR9VCDFQGZNzgNqbqu5WUwlr.cAxZJ9m22Le7' \
3 -H "Content-Type: multipart/form-data; boundary=UNIQUE_BOUNDARY_TOKEN" \
4 --data-binary @/tmp/files-payload \
5 https://developer-stg-api.magento.com/rest/v1/files/uploads

Each record in the list has the following fields:

FieldTypeDescription
filenamestringThe name of the file sent in the request.
content-typestringThe mime-type of the uploaded file.
sizeintegerThe size of the file in bytes.
file_upload_idstringA unique identifier for the file.

The file_upload_id must be tracked for subsequent package submission API endpoints.

  • Privacy
  • Terms of Use
  • Do not sell my personal information
  • AdChoices
Copyright © 2022 Adobe. All rights reserved.