@@ -36,13 +36,48 @@ public function url($path)
36
36
return $ this ->adapter ->publicUrl ($ path , new Config );
37
37
}
38
38
39
- /** @phpstan-ignore-next-line */
39
+ /**
40
+ * Get a temporary URL for the file at the given path.
41
+ *
42
+ * @param string $path
43
+ * @param \DateTimeInterface $expiration
44
+ * @return string
45
+ */
46
+ /** @phpstan-ignore-next-line */
40
47
public function temporaryUrl ($ path , $ expiration , array $ options = [])
41
48
{
42
49
return $ this ->adapter ->temporaryUrl (
43
50
$ path ,
44
51
$ expiration ,
45
- new Config (['permissions ' => 'r ' ])
52
+ new Config (array_merge ( ['permissions ' => 'r ' ], $ options ) )
46
53
);
47
54
}
55
+
56
+ /**
57
+ * Get a temporary upload URL for the file at the given path.
58
+ *
59
+ * @param string $path
60
+ * @param \DateTimeInterface $expiration
61
+ * @return array{url: string, headers: array<string, string>}
62
+ */
63
+ /** @phpstan-ignore-next-line */
64
+ public function temporaryUploadUrl ($ path , $ expiration , array $ options = [])
65
+ {
66
+ $ url = $ this ->adapter ->temporaryUrl (
67
+ $ path ,
68
+ $ expiration ,
69
+ new Config (array_merge (['permissions ' => 'cw ' ], $ options ))
70
+ );
71
+ $ contentType = isset ($ options ['content-type ' ]) && is_string ($ options ['content-type ' ])
72
+ ? $ options ['content-type ' ]
73
+ : 'application/octet-stream ' ;
74
+
75
+ return [
76
+ 'url ' => $ url ,
77
+ 'headers ' => [
78
+ 'x-ms-blob-type ' => 'BlockBlob ' ,
79
+ 'Content-Type ' => $ contentType ,
80
+ ],
81
+ ];
82
+ }
48
83
}
0 commit comments