Import Media
Import Media using the OpenDataBio R package
less than a minute
Attention
1. You basically need the media files in a single folder and a table containing the attributes for each media file;
1. See the [POST Media API docs](/docs/api/post-data/#post-media) to understand which columns can be declared when importing Media. Only 3 columns are mandatory in the attribute table: `filename`, `object_type`, and `object_id`, but it is important to include additional information about the file, such as date, authors, title, usage license, dataset, and also Tags.
1. Consider adding at least one keyword (Tag) for each media file.Importing Media via API
The method below can be done either through the API using the R package or through the web interface. Test and use whichever is faster to upload the image files.
library(opendatabio)
base_url = "https://opendb.inpa.gov.br/api"
token = "GZ1iXcmRvIFQ"
cfg = odb_config(base_url = base_url)
# path to the folder where the images are stored
folder = 'imagesParaOdb'
# list the file names
filenames = dir(folder, full.names = FALSE)
# read the attribute table
attributes = read.table('arquivoAtributos.csv', sep = ',', header = TRUE, as.is = TRUE, na.strings = c("", "NA", "-"))
# are all files listed in the attribute table?
print(paste(sum(filenames %in% attributes$filename), "of", length(filenames), "files are listed in the attribute table"))
# import to ODB
odb_upload_media_zip(folder = folder, attribute_table = attributes, odb_cfg = cfg)