Upload Storage Object
Upload an object stored on the Indico Platform
Introduction
With Indico SDK, one can upload arbitrary files to create storage objects for further consumption by other parts of the platform, creating a submission, for example.
UploadDocument
Inputs
UploadDocument Inputs
file: Binary data of a specific file.
Outputs
UploadDocument Outputs
List of objects
The returned result is a list of objects, in the same order of the upload, containing:
filename
: the original file namefilemeta
:path
: the storage path on Indico platformname
: the same original file name duplicated in this sectionuploadType
: the upload type of a storage object, almost always with the valueuser
returned for an upload initiated from the SDK
Alternatively CreateStorageURLs
can be used in place of UploadDocument
where the returned result is just a list of indico storage urls.
Try It Out
You can try outUploadDocument
below.
import os
from pathlib import Path
from indico.client import IndicoClient
from indico.queries import UploadDocument
client = IndicoClient()
# Prepare files
file_names = ["my_document.pdf", "my_other_document.pdf"]
parent_path = str(Path(__file__).parent.parent / "data")
filepaths = [os.path.join(parent_path, file_name) for file_name in file_names]
# Upload files
uploaded_files = client.call(UploadDocument(files=filepaths))
using IndicoV2;
// With provided token and host
var client = new IndicoClient(token, new Uri(host));
var storageClient = client.Storage();
// Prepare files
var fileNames = new List<string> {"my_document.pdf", "my_other_document.pdf"};
var filePaths = new List<string>();
foreach (string fileName in fileNames) {
filePaths.add("./" + fileName);
}
// Upload files
var uploadedFiles = await storageClient.UploadAsync(filePaths, default);
import com.indico.IndicoClient;
import com.indico.IndicoKtorClient;
import com.indico.storage.UploadFile;
import java.util.Arrays;
import java.util.List;
import org.json.JSONArray;
// Create client with config provided
IndicoClient client = new IndicoKtorClient(config);
UploadFile uploadFile = client.uploadFile();
// Prepare files
List<String> fileNames = Arrays.asList("my_document.pdf", "my_other_document.pdf");
List<String> filePaths = Arrays.asList();
for (fileName : fileNames) {
filePaths.add("./" + fileName);
}
// Upload files
JSONArray uploadedFiles = uploadFile.filePaths(filePaths).call();
Updated 10 months ago
What’s Next
Thinking about making a round trip? We thought the same. Check out: