| @@ 161-184 (lines=24) @@ | ||
| 158 | * |
|
| 159 | * @return string |
|
| 160 | */ |
|
| 161 | private function _createPath($container, $blob = '') |
|
| 162 | { |
|
| 163 | if (empty($blob)) { |
|
| 164 | if (!empty($container)) { |
|
| 165 | return $container; |
|
| 166 | } else { |
|
| 167 | return '/' . $container; |
|
| 168 | } |
|
| 169 | } else { |
|
| 170 | $encodedBlob = urlencode($blob); |
|
| 171 | // Unencode the forward slashes to match what the server expects. |
|
| 172 | $encodedBlob = str_replace('%2F', '/', $encodedBlob); |
|
| 173 | // Unencode the backward slashes to match what the server expects. |
|
| 174 | $encodedBlob = str_replace('%5C', '/', $encodedBlob); |
|
| 175 | // Re-encode the spaces (encoded as space) to the % encoding. |
|
| 176 | $encodedBlob = str_replace('+', '%20', $encodedBlob); |
|
| 177 | // Empty container means accessing default container |
|
| 178 | if (empty($container)) { |
|
| 179 | return $encodedBlob; |
|
| 180 | } else { |
|
| 181 | return '/' . $container . '/' . $encodedBlob; |
|
| 182 | } |
|
| 183 | } |
|
| 184 | } |
|
| 185 | ||
| 186 | /** |
|
| 187 | * Creates full URI to the given blob. |
|
| @@ 83-106 (lines=24) @@ | ||
| 80 | * |
|
| 81 | * @return string |
|
| 82 | */ |
|
| 83 | private function createPath($share, $directory = '') |
|
| 84 | { |
|
| 85 | if (empty($directory)) { |
|
| 86 | if (!empty($share)) { |
|
| 87 | return $share; |
|
| 88 | } else { |
|
| 89 | return '/' . $share; |
|
| 90 | } |
|
| 91 | } else { |
|
| 92 | $encodedFile = urlencode($directory); |
|
| 93 | // Unencode the forward slashes to match what the server expects. |
|
| 94 | $encodedFile = str_replace('%2F', '/', $encodedFile); |
|
| 95 | // Unencode the backward slashes to match what the server expects. |
|
| 96 | $encodedFile = str_replace('%5C', '/', $encodedFile); |
|
| 97 | // Re-encode the spaces (encoded as space) to the % encoding. |
|
| 98 | $encodedFile = str_replace('+', '%20', $encodedFile); |
|
| 99 | // Empty share means accessing default share |
|
| 100 | if (empty($share)) { |
|
| 101 | return $encodedFile; |
|
| 102 | } else { |
|
| 103 | return '/' . $share . '/' . $encodedFile; |
|
| 104 | } |
|
| 105 | } |
|
| 106 | } |
|
| 107 | ||
| 108 | /** |
|
| 109 | * Helper method to create promise for getShareProperties API call. |
|