public function stream_close()
    {
        @fclose($this->temporaryFileHandle);

        // Upload the file?
        if ($this->writeMode) {
            // Make sure the container exists
            $containerExists = $this->getStorageClient($this->fileName)->containerExists(
                $this->getContainerName($this->fileName)
            );
            if (!$containerExists) {
                $this->getStorageClient($this->fileName)->createContainer(
                    $this->getContainerName($this->fileName)
                );
            }

            // Upload the file
            try {
                $this->getStorageClient($this->fileName)->putBlob(
                    $this->getContainerName($this->fileName),
                    $this->getFileName($this->fileName),
                    $this->temporaryFileName
                );
            } catch (BlobException $ex) {
                @unlink($this->temporaryFileName);
                unset($this->storageClient);

                throw $ex;
            }
        }

        @unlink($this->temporaryFileName);
        unset($this->storageClient);
    }