Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The pass "pass.pkpass" could not be opened #51

Closed
dariye opened this issue Jul 17, 2015 · 6 comments
Closed

The pass "pass.pkpass" could not be opened #51

dariye opened this issue Jul 17, 2015 · 6 comments

Comments

@dariye
Copy link

dariye commented Jul 17, 2015

I keep getting this error: The pass "pass.pkpass" could not be opened. Below's my code. I've re-done the cert process like 3 times. Not sure where it's failing because the package seems intact.

def show
   pass = Pass.find(params[:id])
   pass_path = ENV['passes_folder_path'] + "/passes/#{pass.id}"
   pass_json = File.read(pass_path + "/pass.json")
   pkpass = Passbook::PKPass.new pass_json
   files = []
   Dir.foreach(pass_path) do |file|
     next if file == '.' or file == '..' or file == '.DS_Store'
     files << file
   end
   pkpass.addFiles files
   send_data(pkpass, type: 'application/vnd.apple.pkpass', disposition: 'attachment', filename: 'pass.pkpass', status: 201, location: [:api, pass])
 end
@frozon
Copy link
Owner

frozon commented Jul 17, 2015

You can not send pkpass as is in send_data
You have to call pkpass.file.path which will return the temporary pkpass file path

Sorry it could be a little bit more documented. Will update doc in order to get that a bit more clear.

Let me know if it solved your issue.

@dariye
Copy link
Author

dariye commented Jul 17, 2015

WOW! thanks for the prompt response. That returns nil for me.

@dariye
Copy link
Author

dariye commented Jul 17, 2015

screen shot 2015-07-17 at 10 33 30 am

@frozon
Copy link
Owner

frozon commented Jul 17, 2015

This time it is something different. You are only giving the filename and not the file path.

Dir.foreach(pass_path) do |file|
  next if file == '.' or file == '..' or file == '.DS_Store'
  files << File.join(pass_path, file)
end

This should solve this other issue.

@dariye
Copy link
Author

dariye commented Jul 17, 2015

ah! okay. I'll. Worked like a charm! BTW, I'd love to help with documentation and contributing.

@dariye dariye closed this as completed Jul 17, 2015
@rmosolgo
Copy link

I'm sending pkpass responses like this:

pkpass = Passbook::PKPass.new # ... initialize & add files
send_data(pkpass.stream.string, filename: "pass.pkpass", content_type: "application/vnd.apple.pkpass") 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants