matthewbdaly/laravel-azure-storage

Getting the url of the file

stueynet opened this issue · 2 comments

Great project! Thanks so much for it. I am looking at getting the URL for the azure resource. The current implementation only allows to grab the file contents like so:

$fileData = Storage::get($path);

Would then like to let the user download the file. Any thoughts on the best way to handle that?

It's possible to get the file fairly easily from Azure using the config details. Before I created this package I used Graham Campbell's Flysystem package for storing documents on Azure and I had to construct the URL as follows:

$url = 'https://' . config('filesystems.disks.azure.name'). '.blob.core.windows.net/' . config('filesystems.disks.azure.container') . '/' . $filename;

While I haven't used Azure for a while, this should still work unless the naming scheme has drastically changed in the meantime. I will add this to the README for future reference. It'd probably be a good idea to create a reusable helper for your own use case.

It does look like actually getting Storage::get($path) working with Azure isn't likely to be practical. If you look at the url($path) method in https://github.com/laravel/framework/blob/c91c742eb1f6a0cefacde3a558566081f7738f2c/src/Illuminate/Filesystem/FilesystemAdapter.php which actually does the work, it explicitly specifies the adapters that have this functionality. Implementing support for this would therefore be a case of extending that class and adding support for it there, and amending how the framework resolves that particular interface. Extending core parts of the framework like that could be fairly dodgy, so I'm very reluctant to go down that road.

Put it this way, as far as I can see it would be easier to just add this functionality to Laravel itself, but considering the relatively small profile Azure has among Laravel developers compared to S3, I'd be surprised if Taylor Otwell wanted to add that functionality to the core framework. For one piece of functionality that can be duplicated by a simple helper function, it's probably not worth it.

Thanks @matthewbdaly that makes sense. So essentially just construct the url myself based on the expected url from azure. I would image those don't change too often and are hopefully backward compatible. Would probably make sense to set up a subdomain anyway.

Thanks for the response!