public function storeAndAttachFile(File $file, AttachableObjectInterface $object, $fieldName = null, $deleteAfterCopy = null, $customFilename = null)
    {
        $this->checkAttachableObject($object);
        
        if (null === $deleteAfterCopy)
        {
            $deleteAfterCopy = $this->guessDeleteAfterCopy($file, $object, $fieldName);
        }
        
        $this->checkFile($file, $deleteAfterCopy);
        
        $fileKey = $this->generateKey($file, $object, $fieldName);
        $this->copyToStorage($file, $fileKey);
        
        $attachment = $this->saveToDatabase($file, $object, $fieldName, $fileKey, $customFilename);
        
        if ($deleteAfterCopy)
        {
            unlink($file->getRealPath());
        }
        
        return $attachment;
    }