@@ -24,6 +24,65 @@ Then add this to the disks section of config/filesystems.php:
2424],
2525```
2626
27+ ## Usage
28+
29+ ### Example: Upload a File
30+
31+ Example of how to upload a file to Azure Blob Storage:
32+
33+ ``` php
34+ use Illuminate\Support\Facades\Storage;
35+
36+ $file = $request->file('file'); // Assuming a file upload from a request
37+
38+ // Generate a unique file name with extension
39+ $fileName = uniqid() . '.' . $file->getClientOriginalExtension();
40+
41+ // Upload the file to Azure Blob Storage
42+ $path = Storage::disk('azure')->putFileAs('', $file, $fileName);
43+
44+ return response()->json([
45+ 'message' => 'File uploaded successfully'
46+ ]);
47+ ```
48+
49+ ### Example: Get File URL
50+
51+ #### Permanent URL
52+
53+ To get a public URL (if the blob container is set to allow public access):
54+
55+ ``` php
56+ use Illuminate\Support\Facades\Storage;
57+
58+ $filePath = 'example-file.txt'; // Relative path of the file in the container
59+
60+ $url = Storage::disk('azure')->url($filePath);
61+
62+ return response()->json([
63+ 'file_url' => $url, // Permanent public URL
64+ ]);
65+ ```
66+
67+ #### Temporary URL
68+
69+ To generate a temporary URL (with an expiration time for secure access):
70+
71+ ``` php
72+ use Illuminate\Support\Facades\Storage;
73+
74+ $filePath = 'example-file.txt'; // Relative path of the file in the container
75+
76+ $temporaryUrl = Storage::disk('azure')->temporaryUrl(
77+ $filePath,
78+ now()->addMinutes(30) // Set the expiration time, e.g., 30 minutes
79+ );
80+
81+ return response()->json([
82+ 'temporary_url' => $temporaryUrl, // Temporary access URL
83+ ]);
84+ ```
85+
2786## Support
2887
2988Do you need help, do you want to talk to us, or is there anything else?
0 commit comments