첨부 파일을 모델링하는 방법 (s3의 경로 및 URL 체계와 같은)에 따라 다르지만 가장 일반적인 시나리오에서 파생되어야하는 필수 특성 (파일 이름 포함)을 사용하여 개체를 간단히 만들 수 있습니다 upload_url 값 그런 다음 업로드 레코드는 원래 Paperclip을 통해 만들어진 것처럼 액세스 할 수 있습니다.
1.9.3p194 :069 > u = Attachment.new
=> #<Attachment id: nil, type: nil, attachable_id: nil, attachable_type: nil, attachment_file_name: nil, attachment_content_type: nil, attachment_file_size: nil, attachment_updated_at: nil, created_at: nil, updated_at: nil>
1.9.3p194 :070 > u.attachment_file_name = 'fdssfd.txt'
=> "fdssfd.txt"
1.9.3p194 :071 > u.attachment
=> /system/assets/images/paperclip/development//original/fdssfd.txt
1.9.3p194 :072 > u.save
(0.3ms) BEGIN
SQL (0.5ms) INSERT INTO `attachments` (`attachable_id`, `attachable_type`, `attachment_content_type`, `attachment_file_name`, `attachment_file_size`, `attachment_updated_at`, `created_at`, `type`, `updated_at`) VALUES (NULL, NULL, NULL, 'fdssfd.txt', NULL, NULL, '2012-09-18 14:24:26', NULL, '2012-09-18 14:24:26')
[paperclip] Saving attachments.
(1.4ms) COMMIT
=> true
1.9.3p194 :073 > u.attachment
=> /system/assets/images/paperclip/development/5/original/fdssfd.txt
감사합니다. 이것은 매우 만족스러운 해결책으로 느껴지지 않지만 내 유일한 옵션 일 수 있으며 데이터를 내 서버로 전송하고 S3로 되돌려 보내지 않아도됩니다. – kpopper
계속 살펴볼 것이지만 이런 식으로 끝날 수도 있습니다. 건배. – kpopper
업로드 된 파일의 URL 또는 파일의 데이터를 클립 클립에 어떻게 첨부합니까? – rigyt