Upload pdf to amazon in Rails
I have rails app which works with pdf files using PDFKit.
I have no problems with
kit = PDFKit.new(data)
kit.to_file("some.pdf")
What I need as result - save my pdf to Amazon S3. How is it possible to save it directly to the S3 or upload it from tmp/ folder (as I'm going to deploy it on Heroku)
ruby-on-rails ruby-on-rails-3 ruby-on-rails-4 amazon-s3 ruby-on-rails-5
|
show 3 more comments
I have rails app which works with pdf files using PDFKit.
I have no problems with
kit = PDFKit.new(data)
kit.to_file("some.pdf")
What I need as result - save my pdf to Amazon S3. How is it possible to save it directly to the S3 or upload it from tmp/ folder (as I'm going to deploy it on Heroku)
ruby-on-rails ruby-on-rails-3 ruby-on-rails-4 amazon-s3 ruby-on-rails-5
1
I'd recommend you to read about ActiveStorage. (you can user Carrierwave or Paperclip too if you use older Rails versions or you just prefer them).
– arieljuod
Nov 22 '18 at 1:27
I suppose the best way is to use active storage. I was trying to make it work for almost whole day.... Can you give me a hint with code how to make it work? @arieljuod
– Alex Alex
Nov 22 '18 at 3:12
2
I'm not sure where are you stuck, check the official docs edgeguides.rubyonrails.org/active_storage_overview.html. You can find how to configure the s3 service, you set ahas_one_attached :pdf_file
on the model and then you can do something likeyour_object.pdf_file.attach(pdf_file_object)
.
– arieljuod
Nov 22 '18 at 3:44
Well, I have addedhas_one_attached :pdf_file
to my Page model and try to call<% Page.pdf_file.attach(io: File.open('tmp/'), filename: 'some.pdf') %>
. As the result I getundefined method 'pdf_file' for Page(id: integer, created_at: datetime, updated_at: datetime):Class
@arieljuod
– Alex Alex
Nov 22 '18 at 18:54
Could you write simple code example for model, controller and view please? @arieljuod
– Alex Alex
Nov 22 '18 at 20:17
|
show 3 more comments
I have rails app which works with pdf files using PDFKit.
I have no problems with
kit = PDFKit.new(data)
kit.to_file("some.pdf")
What I need as result - save my pdf to Amazon S3. How is it possible to save it directly to the S3 or upload it from tmp/ folder (as I'm going to deploy it on Heroku)
ruby-on-rails ruby-on-rails-3 ruby-on-rails-4 amazon-s3 ruby-on-rails-5
I have rails app which works with pdf files using PDFKit.
I have no problems with
kit = PDFKit.new(data)
kit.to_file("some.pdf")
What I need as result - save my pdf to Amazon S3. How is it possible to save it directly to the S3 or upload it from tmp/ folder (as I'm going to deploy it on Heroku)
ruby-on-rails ruby-on-rails-3 ruby-on-rails-4 amazon-s3 ruby-on-rails-5
ruby-on-rails ruby-on-rails-3 ruby-on-rails-4 amazon-s3 ruby-on-rails-5
asked Nov 22 '18 at 0:27
Alex AlexAlex Alex
12
12
1
I'd recommend you to read about ActiveStorage. (you can user Carrierwave or Paperclip too if you use older Rails versions or you just prefer them).
– arieljuod
Nov 22 '18 at 1:27
I suppose the best way is to use active storage. I was trying to make it work for almost whole day.... Can you give me a hint with code how to make it work? @arieljuod
– Alex Alex
Nov 22 '18 at 3:12
2
I'm not sure where are you stuck, check the official docs edgeguides.rubyonrails.org/active_storage_overview.html. You can find how to configure the s3 service, you set ahas_one_attached :pdf_file
on the model and then you can do something likeyour_object.pdf_file.attach(pdf_file_object)
.
– arieljuod
Nov 22 '18 at 3:44
Well, I have addedhas_one_attached :pdf_file
to my Page model and try to call<% Page.pdf_file.attach(io: File.open('tmp/'), filename: 'some.pdf') %>
. As the result I getundefined method 'pdf_file' for Page(id: integer, created_at: datetime, updated_at: datetime):Class
@arieljuod
– Alex Alex
Nov 22 '18 at 18:54
Could you write simple code example for model, controller and view please? @arieljuod
– Alex Alex
Nov 22 '18 at 20:17
|
show 3 more comments
1
I'd recommend you to read about ActiveStorage. (you can user Carrierwave or Paperclip too if you use older Rails versions or you just prefer them).
– arieljuod
Nov 22 '18 at 1:27
I suppose the best way is to use active storage. I was trying to make it work for almost whole day.... Can you give me a hint with code how to make it work? @arieljuod
– Alex Alex
Nov 22 '18 at 3:12
2
I'm not sure where are you stuck, check the official docs edgeguides.rubyonrails.org/active_storage_overview.html. You can find how to configure the s3 service, you set ahas_one_attached :pdf_file
on the model and then you can do something likeyour_object.pdf_file.attach(pdf_file_object)
.
– arieljuod
Nov 22 '18 at 3:44
Well, I have addedhas_one_attached :pdf_file
to my Page model and try to call<% Page.pdf_file.attach(io: File.open('tmp/'), filename: 'some.pdf') %>
. As the result I getundefined method 'pdf_file' for Page(id: integer, created_at: datetime, updated_at: datetime):Class
@arieljuod
– Alex Alex
Nov 22 '18 at 18:54
Could you write simple code example for model, controller and view please? @arieljuod
– Alex Alex
Nov 22 '18 at 20:17
1
1
I'd recommend you to read about ActiveStorage. (you can user Carrierwave or Paperclip too if you use older Rails versions or you just prefer them).
– arieljuod
Nov 22 '18 at 1:27
I'd recommend you to read about ActiveStorage. (you can user Carrierwave or Paperclip too if you use older Rails versions or you just prefer them).
– arieljuod
Nov 22 '18 at 1:27
I suppose the best way is to use active storage. I was trying to make it work for almost whole day.... Can you give me a hint with code how to make it work? @arieljuod
– Alex Alex
Nov 22 '18 at 3:12
I suppose the best way is to use active storage. I was trying to make it work for almost whole day.... Can you give me a hint with code how to make it work? @arieljuod
– Alex Alex
Nov 22 '18 at 3:12
2
2
I'm not sure where are you stuck, check the official docs edgeguides.rubyonrails.org/active_storage_overview.html. You can find how to configure the s3 service, you set a
has_one_attached :pdf_file
on the model and then you can do something like your_object.pdf_file.attach(pdf_file_object)
.– arieljuod
Nov 22 '18 at 3:44
I'm not sure where are you stuck, check the official docs edgeguides.rubyonrails.org/active_storage_overview.html. You can find how to configure the s3 service, you set a
has_one_attached :pdf_file
on the model and then you can do something like your_object.pdf_file.attach(pdf_file_object)
.– arieljuod
Nov 22 '18 at 3:44
Well, I have added
has_one_attached :pdf_file
to my Page model and try to call <% Page.pdf_file.attach(io: File.open('tmp/'), filename: 'some.pdf') %>
. As the result I get undefined method 'pdf_file' for Page(id: integer, created_at: datetime, updated_at: datetime):Class
@arieljuod– Alex Alex
Nov 22 '18 at 18:54
Well, I have added
has_one_attached :pdf_file
to my Page model and try to call <% Page.pdf_file.attach(io: File.open('tmp/'), filename: 'some.pdf') %>
. As the result I get undefined method 'pdf_file' for Page(id: integer, created_at: datetime, updated_at: datetime):Class
@arieljuod– Alex Alex
Nov 22 '18 at 18:54
Could you write simple code example for model, controller and view please? @arieljuod
– Alex Alex
Nov 22 '18 at 20:17
Could you write simple code example for model, controller and view please? @arieljuod
– Alex Alex
Nov 22 '18 at 20:17
|
show 3 more comments
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53422291%2fupload-pdf-to-amazon-in-rails%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53422291%2fupload-pdf-to-amazon-in-rails%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
I'd recommend you to read about ActiveStorage. (you can user Carrierwave or Paperclip too if you use older Rails versions or you just prefer them).
– arieljuod
Nov 22 '18 at 1:27
I suppose the best way is to use active storage. I was trying to make it work for almost whole day.... Can you give me a hint with code how to make it work? @arieljuod
– Alex Alex
Nov 22 '18 at 3:12
2
I'm not sure where are you stuck, check the official docs edgeguides.rubyonrails.org/active_storage_overview.html. You can find how to configure the s3 service, you set a
has_one_attached :pdf_file
on the model and then you can do something likeyour_object.pdf_file.attach(pdf_file_object)
.– arieljuod
Nov 22 '18 at 3:44
Well, I have added
has_one_attached :pdf_file
to my Page model and try to call<% Page.pdf_file.attach(io: File.open('tmp/'), filename: 'some.pdf') %>
. As the result I getundefined method 'pdf_file' for Page(id: integer, created_at: datetime, updated_at: datetime):Class
@arieljuod– Alex Alex
Nov 22 '18 at 18:54
Could you write simple code example for model, controller and view please? @arieljuod
– Alex Alex
Nov 22 '18 at 20:17