Ruby on Rails
Wednesday, January 25, 2017
Problem: I have use the net/http code for uploading the '.doc', '.docx', '.pdf' and images files on dropbox. But I getting the issues like:
1.invalid byte sequence in UTF 8
2. Now while the file is uploading but it not uploading the content and even it uploading as a corrupt file.
Below I writing my code to upload the file on dropbox. Please help me.
Code:
uri = URI.parse("https://content.dropboxapi.com/2/files/upload")
request = Net::HTTP::Post.new(uri)
request.content_type = "application/octet-stream"
request["Authorization"] = "Bearer #{$acess_token}"
request["Dropbox-Api-Arg"] = "{\"path\":\"/Sass-for-Web-Designers.pdf\"}"
request.body = ""
request.body << File.open("app/assets/images/categoryImages/Sass-for-Web-Designers.pdf").read
#request.body << file.content
#file.close
Subscribe to:
Post Comments (Atom)
Blog Archive
- August 2024 (1)
- April 2024 (1)
- July 2023 (1)
- February 2023 (38)
- November 2021 (1)
- January 2021 (1)
- December 2020 (1)
- March 2020 (49)
- February 2020 (59)
- January 2020 (109)
- December 2019 (130)
- November 2019 (77)
- October 2019 (106)
- September 2019 (66)
- August 2019 (96)
- July 2019 (27)
- June 2019 (52)
- May 2019 (51)
- April 2019 (53)
- March 2019 (115)
- February 2019 (153)
- January 2019 (222)
- December 2018 (155)
- November 2018 (104)
- October 2018 (164)
- September 2018 (89)
- August 2018 (209)
- July 2018 (126)
- June 2018 (171)
- May 2018 (80)
- April 2018 (81)
- March 2018 (126)
- February 2018 (161)
- January 2018 (153)
- December 2017 (55)
- November 2017 (53)
- October 2017 (96)
- September 2017 (250)
- August 2017 (99)
- July 2017 (253)
- June 2017 (175)
- May 2017 (94)
- April 2017 (140)
- March 2017 (126)
- February 2017 (148)
- January 2017 (80)
- December 2016 (116)
- November 2016 (56)
- October 2016 (105)
- September 2016 (38)
- August 2016 (100)
- July 2016 (173)
- June 2016 (192)
- May 2016 (177)
- April 2016 (211)
- March 2016 (318)
- February 2016 (269)
- January 2016 (346)
- December 2015 (363)
- November 2015 (380)
- October 2015 (269)
- September 2015 (365)
- August 2015 (287)
- July 2015 (539)
- June 2015 (430)
- May 2015 (337)
- April 2015 (453)
- March 2015 (350)
- February 2015 (386)
- January 2015 (436)
- December 2014 (431)
- November 2014 (371)
- October 2014 (319)
- September 2014 (423)
- August 2014 (475)
- July 2014 (505)
- June 2014 (444)
- May 2014 (601)
- April 2014 (489)
- March 2014 (486)
- February 2014 (396)
- January 2014 (429)
- December 2013 (323)
- November 2013 (371)
- October 2013 (488)
- September 2013 (438)
- August 2013 (442)
- July 2013 (651)
- June 2013 (557)
- May 2013 (751)
- April 2013 (582)
- March 2013 (775)
- February 2013 (588)
- January 2013 (697)
- December 2012 (682)
- November 2012 (830)
- October 2012 (879)
- September 2012 (1091)
- August 2012 (851)
- July 2012 (872)
- June 2012 (874)
- May 2012 (845)
- April 2012 (979)
- March 2012 (1003)
- February 2012 (1272)
- January 2012 (1291)
- December 2011 (1184)
- November 2011 (1160)
- October 2011 (1107)
- September 2011 (1184)
- August 2011 (1451)
- July 2011 (1313)
- June 2011 (1174)
- May 2011 (1351)
- April 2011 (1364)
- March 2011 (1429)
- February 2011 (1332)
- January 2011 (1427)
- December 2010 (1464)
- November 2010 (1456)
- October 2010 (1460)
- September 2010 (1467)
- August 2010 (1496)
- July 2010 (1500)
- June 2010 (1411)
- May 2010 (1418)
- April 2010 (1054)
No comments:
Post a Comment