I have a requirement in M2 where I need the shareable file link of downloadable product.
$product = $this->productRepository->getById($productId);
// Output array
$output = [];
// Get the product downloadable links
$links = $this->linkRepository->getLinksByProduct($product);
// Add each link data to the output array
foreach ($links as $item) {
$output[] = $item->getData();
}
This piece of code is returning the details with relative path, I want the shareable file link which I can share with others and they can also download, is it possible?