protected function flushWrites()
    {
        // Skip this if there is no queued write items
        if (count($this->getQueue('write')) === 0) {
            return;
        }

        // Update the state of the queued attachment
        $this->updateQueueState(self::QUEUE_WORKING);

        foreach ($this->getQueue('write') as $name => $style) {
            if ($style && $this->uploaded_file->isImage()) {
                $file = $this->getResizer()
                    ->resize($this->uploaded_file, $style);
            }
            else {
                $file = $this->uploaded_file->getRealPath();
            }

            // Only move it real
            if ($filePath = $this->path($name)) {
                $this->move($file, $filePath);
            }
        }

        $this->resetQueue('write');

        // Update the state of the queued attachment
        $this->updateQueueState(self::QUEUE_DONE);
    }