Skip to content

ndi.cloud.upload.upload_document_collection

  UPLOAD_DOCUMENT_COLLECTION - Upload a collection of documents using bulk or serial upload.

    [b, report] = ndi.cloud.upload.upload_document_collection(datasetId, documentList, options)
    performs an upload of documents to a specified dataset. The method (batch vs. serial)
    and batch size can be controlled.

    By default, it uses a bulk upload process. It creates ZIP archives from the
    document list, retrieves bulk upload URLs, and uploads the ZIP files to the cloud.
    This process can be broken into chunks using the 'maxDocumentChunk' option.

    If the environment variable 'NDI_CLOUD_UPLOAD_NO_ZIP' is set to 'true',
    the documents are uploaded one at a time via a slower serial process.

  INPUTS:
    datasetId      - (1,1) string
                     The unique identifier for the target NDI Cloud dataset.

    documentList   - (1,:) cell
                     A cell array of ndi.document objects to be uploaded.

    options.maxDocumentChunk - (1,1) double
                     The maximum number of documents to include in a single ZIP
                     archive for batch uploads. Defaults to Inf (all documents
                     in one batch).

  OUTPUTS:
    b              - (1,1) logical
                     A boolean that is true if the entire upload operation
                     succeeded and false otherwise.

    report         - (1,1) struct
                     A structure containing a report of the upload operation.
                     It will have the following fields:
                     'uploadType': 'batch' or 'serial'.
                     'manifest': For 'batch' type, a cell array where each entry
                                 is a cell array of document IDs in that batch.
                                 For 'serial' type, this is a cell array of
                                 individual document IDs.
                     'status': A cell array with 'success' or 'failure' for
                               each corresponding entry in the manifest.

  EXAMPLE:
    % Upload a collection of documents in chunks of 100
    docs = {doc_obj1, doc_obj2, ..., doc_obj250};
    [success, uploadReport] = ndi.cloud.upload.upload_document_collection("dataset123", docs, maxDocumentChunk=100);

  See also:
    ndi.cloud.api.documents.get_bulk_upload_url
    ndi.cloud.upload.internal.zip_documents_for_upload