{"id":19135,"date":"2016-04-08T20:00:32","date_gmt":"2016-04-08T17:00:32","guid":{"rendered":"https:\/\/www.altoros.com\/blog\/?p=19135"},"modified":"2019-06-20T04:00:17","modified_gmt":"2019-06-20T01:00:17","slug":"uploading-files-to-ibm-bluemix-object-storage-a-sample-app","status":"publish","type":"post","link":"https:\/\/www.altoros.com\/blog\/uploading-files-to-ibm-bluemix-object-storage-a-sample-app\/","title":{"rendered":"Uploading Files to IBM Bluemix Object Storage: A Sample App"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.altoros.com\/blog\/uploading-files-to-ibm-bluemix-object-storage-a-sample-app\/#Saving_objects_on_Bluemix\" >Saving objects on Bluemix<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.altoros.com\/blog\/uploading-files-to-ibm-bluemix-object-storage-a-sample-app\/#An_IBM_Object_Storage_overview\" >An IBM Object Storage overview<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.altoros.com\/blog\/uploading-files-to-ibm-bluemix-object-storage-a-sample-app\/#Creating_the_application\" >Creating the application<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.altoros.com\/blog\/uploading-files-to-ibm-bluemix-object-storage-a-sample-app\/#Adding_the_endpoint_for_uploading_files\" >Adding the endpoint for uploading files<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.altoros.com\/blog\/uploading-files-to-ibm-bluemix-object-storage-a-sample-app\/#Conclusion\" >Conclusion<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.altoros.com\/blog\/uploading-files-to-ibm-bluemix-object-storage-a-sample-app\/#Further_reading\" >Further reading<\/a><\/li><\/ul><\/nav><\/div>\n<h3><span class=\"ez-toc-section\" id=\"Saving_objects_on_Bluemix\"><\/span>Saving objects on Bluemix<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Imagine that you need to deploy an application to a PaaS and this application should allow for uploading files to the server. In such scenario, you cannot just use the local storage of the <a href=\"https:\/\/docs.cloudfoundry.org\/concepts\/diego\/dea-vs-diego.html\" target=\"_blank\" rel=\"noopener noreferrer\">application container<\/a>, because it is ephemeral.<\/p>\n<p>This post shows you how to solve the problem. We will develop a simple application as an example and use <a href=\"https:\/\/cloud.ibm.com\/docs\/services\/ObjectStorage\/index.html\" target=\"_blank\" rel=\"noopener noreferrer\">IBM Bluemix Object Storage<\/a> to host binary files.<\/p>\n<p>The sample application is a form where a user can upload any binary file, a document, image, and so on under a selected category (a container). It also allows for listing files stored in a certain category: <strong>Music<\/strong>, <strong>Images<\/strong>, or <strong>Docs<\/strong>.<\/p>\n<p>The source code for this post is available on <a href=\"https:\/\/github.com\/Altoros\/bluemix-object-store-example\" target=\"_blank\" rel=\"noopener noreferrer\">GitHub<\/a>.<\/p>\n<p>&nbsp;<\/p>\n<h3><span class=\"ez-toc-section\" id=\"An_IBM_Object_Storage_overview\"><\/span>An IBM Object Storage overview<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>IBM Object Storage is built upon Swift, an object\/blob store from OpenStack. The architecture of the <a href=\"https:\/\/docs.openstack.org\/developer\/swift\/api\/object_api_v1_overview.html\" target=\"_blank\" rel=\"noopener noreferrer\">Swift API<\/a> is very similar to Amazon S3: you have buckets and objects in S3, and in Swift, you have containers instead of buckets.<\/p>\n<p>Here are some examples of the Swift API endpoints:<\/p>\n<ul>\n<li>In fact, there is an endpoint to list all available endpoints: <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">GET \/v1\/endpoints<\/code> \ud83d\ude42<\/li>\n<li>Show container details and list objects: <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">GET \/v1\/{account}\/{container}<\/code><\/li>\n<li>Get object content and metadata: <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">GET \/v1\/{account}\/{container}\/{object}<\/code><\/li>\n<li>Create or replace an object: <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">PUT \/v1\/{account}\/{container}\/{object}<\/code><\/li>\n<li>Delete an object: <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">DELETE \/v1\/{account}\/{container}\/{object}<\/code><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Creating_the_application\"><\/span>Creating the application<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>As I\u2019ve mentioned before, the application will have two endpoints: one for uploading a file under a certain category and the other for listing files. Here are my mockups.<\/p>\n<p><center><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2016\/04\/Uploading-files-to-IBM-Bluemix-Object-Storage-creating-the-app-v3-1.png\" alt=\"Uploading-files-to-IBM-Bluemix-Object-Storage-creating-the-app-v3\" width=\"500\" height=\"267\" class=\"aligncenter size-full wp-image-19139\" \/><\/center><\/p>\n<p><center><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2016\/04\/uploading-files-to-ibm-bluemix-storage-v3-1.png\" alt=\"uploading-files-to-ibm-bluemix-storage-v3\" width=\"500\" height=\"275\" class=\"aligncenter size-full wp-image-19141\" \/><\/center><\/p>\n<p>Now, let\u2019s start creating the basic files for the application. Similar to my <a href=\"https:\/\/www.altoros.com\/blog\/video-streaming-in-bluemix-ustream-for-ibm-cloud\/\">previous post<\/a>, I use Cuba. We need four files:<\/p>\n<ul>\n<li><code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">app.rb<\/code><\/li>\n<li><code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">config.ru<\/code><\/li>\n<li><code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">Gemfile<\/code><\/li>\n<li><code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">views\/upload.mote<\/code><\/li>\n<\/ul>\n<p><em>app.rb:<\/em><\/p>\n<pre style=\"padding-left: 30px;\"><code>echo \"require 'cuba'\r\nrequire 'mote'\r\nrequire 'mote\/render'\r\n\r\nCuba.plugin Mote::Render\r\n\r\nCuba.define do\r\n\r\n  on root do\r\n    on get do\r\n      render 'upload'\r\n    end\r\n  end\r\nend\" > app.rb\r\n<\/code><\/pre>\n<p><em>config.ru<\/em><\/p>\n<pre style=\"padding-left: 30px;\"><code>echo \"require '.\/app'\r\nrun Cuba\" > config.ru<\/code><\/pre>\n<p><\/p>\n<p><em>Gemfile.rb<\/em><\/p>\n<pre style=\"padding-left: 30px;\"><code>echo \"source 'https:\/\/rubygems.org'\r\ngem 'cuba'\r\ngem 'mote'\r\ngem 'mote-render'\r\ngem 'pry'\" > Gemfile.rb<\/code><\/pre>\n<p><\/p>\n<p><em>views\/upload.mote<\/em><\/p>\n<pre style=\"padding-left: 30px;\"><code>mkdir views\r\necho '&lt;h1&gt;Upload Your File&lt;\/h1&gt;\r\n\r\n&lt;form method=\"post\" enctype=\"multipart\/form-data\" action=\"\/\"&gt;\r\n  &lt;fieldset&gt;\r\n    &lt;select&gt;\r\n      &lt;option value=\"music\"&gt;Music&lt;\/option&gt;\r\n      &lt;option value=\"images\"&gt;Images&lt;\/option&gt;\r\n      &lt;option value=\"docs\"&gt;Documents&lt;\/option&gt;\r\n    &lt;\/select&gt;\r\n\r\n    &lt;input name=\"file\" type=\"file\"&gt;\r\n    &lt;br \/&gt;&lt;br \/&gt;\r\n    &lt;button type=\"submit\"&gt;Upload&lt;\/button&gt;\r\n  &lt;\/fieldset&gt;\r\n&lt;\/form&gt;' > views\/upload.mote<\/code><\/pre>\n<p>Now, install the required gems:<\/p>\n<pre style=\"padding-left: 30px;\"><code>bundle install<\/code><\/pre>\n<p>If you run the <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">rackup<\/code> command and point your browser at <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">http:\/\/localhost:9292<\/code>, you should see the upload form. It does nothing yet, so we will add a new endpoint to handle the POST request after a user clicks the upload button. Before doing this, add the Open Storage service through the Bluemix dashboard as described in <a href=\"https:\/\/cloud.ibm.com\/docs\/services\/ObjectStorage\/index.html\" target=\"_blank\" rel=\"noopener noreferrer\">Bluemix documentation<\/a>.<\/p>\n<p>Then, you can see your credentials in the Object Storage section on the Bluemix dashboard. With that data, test the service using <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">curl<\/code>:<\/p>\n<pre style=\"padding-left: 30px;\"><code>curl -i \\\r\n-H \"Content-Type: application\/json\" \\\r\n-d '\r\n{\r\n  \"auth\": {\r\n    \"identity\": {\r\n      \"methods\": [\"password\"],\r\n        \"password\": {\r\n          \"user\": {\r\n            \"name\": \"Admin_username\",\r\n            \"domain\": { \"id\": \"domain\" },\r\n            \"password\": \"password\"\r\n          }\r\n        }\r\n     },\r\n     \"scope\": {\r\n       \"project\": {\r\n         \"name\": \"project\",\r\n         \"domain\": { \"id\": \"domainId\" }\r\n        }\r\n      }\r\n     }\r\n}' \\\r\nhttps:\/\/identity.open.softlayer.com\/v3\/auth\/tokens ; echo\r\n<\/code><\/pre>\n<p>You can find more examples in <a href=\"https:\/\/docs.openstack.org\/api-ref\/identity\/v3\/index.html\" target=\"_blank\" rel=\"noopener noreferrer\">OpenStack Documentation<\/a>.<\/p>\n<p>Now, after we have tested the service and made sure it works, we are ready to interact with Object Storage. Let&#8217;s add the <a href=\"https:\/\/github.com\/mrkamel\/swift_client\" target=\"_blank\" rel=\"noopener noreferrer\"><code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">swift_client<\/code><\/a> gem to <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">Gemfile<\/code>:<\/p>\n<pre style=\"padding-left: 30px;\"><code>gem 'swift_client'<\/code><\/pre>\n<p>Then, create the containers in Bluemix from the dashboard by clicking <strong>Add container<\/strong> on the <strong>Action<\/strong> menu. Remember that the application will have three categories (containers): Music, Images, and Documents.<\/p>\n<p><a href=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2016\/04\/uploading-files-to-ibm-bluemix-object-storage-adding-container-1.png\"><img decoding=\"async\" src=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2016\/04\/uploading-files-to-ibm-bluemix-object-storage-adding-container-1.png\" alt=\"uploading-files-to-ibm-bluemix-object-storage-adding-container\" width=\"640\" class=\"aligncenter size-full wp-image-19138\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Adding_the_endpoint_for_uploading_files\"><\/span>Adding the endpoint for uploading files<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>First, we have to connect to a Swift cluster. To do so, add the following module to your <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">app.rb<\/code> file:<\/p>\n<pre style=\"padding-left: 30px;\"><code>module OStorage\r\n  def self.client\r\n    o_storage   = JSON.parse ENV['VCAP_SERVICES']\r\n    credentials = o_storage['Object-Storage'].first['credentials']\r\n\r\n    SwiftClient.new(\r\n      :auth_url          => \"#{ credentials['auth_url'] }\/v3\",\r\n      :username          => credentials['username'],\r\n      :password          => credentials['password'],\r\n      :domain_id         => credentials['domainId'],\r\n      :project_name      => credentials['project'],\r\n      :project_domain_id =>  credentials['domainId'],\r\n      :storage_url       => \"https:\/\/dal.objectstorage.open.softlayer.com\/v1\/AUTH_#{ credentials['projectId'] }\"\r\n)\r\n  end\r\nend\r\n<\/code><\/pre>\n<p>Take into consideration two things that I found out when working on the module:<\/p>\n<ul>\n<li><code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">auth_url<\/code> needs <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">\/v3<\/code> to be included.<\/li>\n<li><code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">storage_url<\/code> has to be like the service documentation describes.<\/li>\n<\/ul>\n<p>Second, to handle file uploading, we have to add a new endpoint to <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">app.rb<\/code> similar to the following:<\/p>\n<pre style=\"padding-left: 30px;\"><code>on post do\r\n    on root do\r\n      OStorage.client.put_object(req['file'][:filename],\r\n                                 req['file'][:tempfile], req['container'])\r\n      res.redirect '\/'\r\n    end\r\n  end\r\nend\r\n<\/code><\/pre>\n<p>With this done, we are able to upload files into an Object Storage directory. We also want to list files under a certain directory. Let\u2019s add a new route under <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">get<\/code>. The entire <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">app.rb<\/code> file is below:<\/p>\n<pre style=\"padding-left: 30px;\"><code>require 'cuba'\r\nrequire 'mote'\r\nrequire 'mote\/render'\r\nrequire 'swift_client'\r\nrequire 'json'\r\n\r\nCuba.plugin Mote::Render\r\n\r\nmodule OStorage\r\n  def self.client\r\n    o_storage   = JSON.parse ENV['VCAP_SERVICES']\r\n    credentials = o_storage['Object-Storage'].first['credentials']\r\n\r\n    SwiftClient.new(\r\n      :auth_url          => \"#{ credentials['auth_url'] }\/v3\",\r\n      :username          => credentials['username'],\r\n      :password          => credentials['password'],\r\n      :domain_id         => credentials['domainId'],\r\n      :project_name      => credentials['project'],\r\n      :project_domain_id =>  credentials['domainId'],\r\n      :storage_url       => \"https:\/\/dal.objectstorage.open.softlayer.com\/v1\/AUTH_#{ credentials['projectId'] }\"\r\n)\r\n  end\r\nend\r\n\r\nCuba.define do\r\n  on get do\r\n    on root do\r\n      container = req.params['container'] || 'music'\r\n      files = OStorage.client.get_objects(container).parsed_response\r\n\r\n      render 'upload', container: container, files: files\r\n    end\r\n  end\r\n\r\n  on post do\r\n    on root do\r\n      OStorage.client.put_object(req['file'][:filename],\r\n                                 req['file'][:tempfile], req['container'])\r\n      res.redirect '\/'\r\n    end\r\n\r\n    on ':container\/:filename' do |container, filename|\r\n      OStorage.client.delete_object(filename, container)\r\n      res.redirect '\/'\r\n    end\r\n\r\n  end\r\n\r\nend\r\n<\/code><\/pre>\n<p>The upload view:<\/p>\n<pre style=\"padding-left: 30px;\"><code>&lt;h1&gt;Upload Your File&lt;\/h1&gt;\r\n&lt;form method=\"post\" enctype=\"multipart\/form-data\"\r\n      action=\"\/\" class=\"form-inline alert alert-info text-center\"&gt;\r\n  &lt;label for=\"container\"&gt;Container:&lt;\/label&gt;\r\n  &lt;select id=\"container\" name=\"container\"&gt;\r\n    &lt;option value=\"music\"&gt;Music&lt;\/option&gt;\r\n    &lt;option value=\"images\"&gt;Images&lt;\/option&gt;\r\n    &lt;option value=\"documents\"&gt;Documents&lt;\/option&gt;\r\n  &lt;\/select&gt;\r\n\r\n  &lt;label for=\"file\"&gt;File:&lt;\/label&gt;\r\n  &lt;input name=\"file\" type=\"file\" class=\"form-control\" id=\"file\"&gt;\r\n  &lt;button type=\"submit\" class=\"btn btn-primary\"&gt;Upload&lt;\/button&gt;\r\n&lt;\/form&gt;\r\n\r\n&lt;ul class=\"nav nav-pills nav-justified\"&gt;\r\n  &lt;li role=\"presentation\" class=\"active\"&gt;&lt;a href=\"\/?container=music\"&gt;Music&lt;\/a&gt;&lt;\/li&gt;\r\n  &lt;li role=\"presentation\"&gt;&lt;a href=\"\/?container=images\"&gt;Images&lt;\/a&gt;&lt;\/li&gt;\r\n  &lt;li role=\"presentation\"&gt;&lt;a href=\"\/?container=documents\"&gt;Documents&lt;\/a&gt;&lt;\/li&gt;\r\n&lt;\/ul&gt;\r\n\r\n% files.each do |f|\r\n  &lt;a href=\"\/file\/{{ f['hash'] }}\"&gt;\r\n    {{ f['name'] }}\r\n  &lt;\/a&gt;\r\n  &lt;form method=\"post\" action=\"{{container}}\/{{ f['name'] }}\"&gt;\r\n    &lt;button type=\"submit\"&gt;Delete&lt;\/button&gt;\r\n  &lt;\/form&gt;&lt;br \/&gt;\r\n% end\r\n&lt;br\/&gt;\r\n<\/code><\/pre>\n<p>Now, deploy the application to Bluemix to see if everything is working properly:<\/p>\n<pre style=\"padding-left: 30px;\"><code>cf push object-storage-example<\/code><\/pre>\n<p>If you have not pushed it before, you need to associate the Object Storage service with your application.<\/p>\n<p>You can visit <a href=\"http:\/\/object-store-example.mybluemix.net\/\" target=\"_blank\" rel=\"noopener noreferrer\">http:\/\/object-store-example.mybluemix.net\/<\/a> to check that the application is working, right? \ud83d\ude42<\/p>\n<p><a href=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2016\/04\/uploading-files-to-ibm-bluemix-object-storage-result-1.gif\"><img decoding=\"async\" src=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2016\/04\/uploading-files-to-ibm-bluemix-object-storage-result-1.gif\" alt=\"uploading-files-to-ibm-bluemix-object-storage-result\" width=\"640\" class=\"aligncenter size-full wp-image-19140\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>The Object Storage service worked well, and everything went as I expected. Creating a service for an application is fast because Bluemix provides credentials for the service and links the service to your application for you. My only concern is that the version of the Swift API is not specified in the Bluemix documentation. Doing so would let users know what version of the Swift API reference to read.<\/p>\n<p>Anyway, you can figure this out by running the <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">curl https:\/\/identity.open.softlayer.com\/<\/code> command.<\/p>\n<p>&nbsp;<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Further_reading\"><\/span>Further reading<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li><a href=\"https:\/\/www.altoros.com\/blog\/the-ibm-bluemix-object-storage-service-in-ruby-projects\/\">Using IBM Bluemix Object Storage in Ruby Projects<\/a><\/li>\n<li><a href=\"https:\/\/www.altoros.com\/blog\/deploying-a-rails-5-app-with-mongodb-redis-and-carrierwave-to-ibm-bluemix\/\">Deploying a Rails 5 App with MongoDB, Redis, and CarrierWave to IBM Bluemix<\/a>\n<\/li>\n<li><a href=\"https:\/\/www.altoros.com\/blog\/deploying-kibana-to-ibm-bluemix-for-exploring-elasticsearch-data\/\">Deploying Kibana to IBM Bluemix for Exploring Elasticsearch Data<\/a><\/li>\n<li><a href=\"https:\/\/www.altoros.com\/blog\/introduction-to-ibm-bluemix-openwhisk\/\">Introduction to IBM Bluemix OpenWhisk<\/a><\/li>\n<li><a href=\"https:\/\/www.altoros.com\/blog\/continuous-integration-and-continuous-delivery-in-ibm-bluemix\/\">Continuous Integration and Continuous Delivery in IBM Bluemix<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<hr\/>\n<p><center><small>The post was written by Gaston Ramos, edited and published by Victoria Fedzkovich and <a href=\"https:\/\/www.altoros.com\/blog\/author\/alex\/\">Alex Khizhniak<\/a>.<\/small><\/center><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Saving objects on Bluemix<\/p>\n<p>Imagine that you need to deploy an application to a PaaS and this application should allow for uploading files to the server. In such scenario, you cannot just use the local storage of the application container, because it is ephemeral.<\/p>\n<p>This post shows you how to solve the [&#8230;]<\/p>\n","protected":false},"author":65,"featured_media":19220,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"content-type":"","footnotes":"","_links_to":"","_links_to_target":""},"categories":[214],"tags":[873,187],"class_list":["post-19135","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-cloud-native","tag-ibm-bluemix"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Uploading Files to IBM Bluemix Object Storage: A Sample App | Altoros<\/title>\n<meta name=\"description\" content=\"The service from IBM can serve as an alternative to AWS S3.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.altoros.com\/blog\/uploading-files-to-ibm-bluemix-object-storage-a-sample-app\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Uploading Files to IBM Bluemix Object Storage: A Sample App | Altoros\" \/>\n<meta property=\"og:description\" content=\"Saving objects on Bluemix Imagine that you need to deploy an application to a PaaS and this application should allow for uploading files to the server. In such scenario, you cannot just use the local storage of the application container, because it is ephemeral. This post shows you how to solve the [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.altoros.com\/blog\/uploading-files-to-ibm-bluemix-object-storage-a-sample-app\/\" \/>\n<meta property=\"og:site_name\" content=\"Altoros\" \/>\n<meta property=\"article:published_time\" content=\"2016-04-08T17:00:32+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-06-20T01:00:17+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2016\/04\/ibm-bluemix-object-storage-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"616\" \/>\n\t<meta property=\"og:image:height\" content=\"364\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Gast\u00f3n Ramos\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Gast\u00f3n Ramos\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.altoros.com\\\/blog\\\/uploading-files-to-ibm-bluemix-object-storage-a-sample-app\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.altoros.com\\\/blog\\\/uploading-files-to-ibm-bluemix-object-storage-a-sample-app\\\/\"},\"author\":{\"name\":\"Gast\u00f3n Ramos\",\"@id\":\"https:\\\/\\\/www.altoros.com\\\/blog\\\/#\\\/schema\\\/person\\\/3bfa3cc42526eb3e6a83df9d634e43f7\"},\"headline\":\"Uploading Files to IBM Bluemix Object Storage: A Sample App\",\"datePublished\":\"2016-04-08T17:00:32+00:00\",\"dateModified\":\"2019-06-20T01:00:17+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.altoros.com\\\/blog\\\/uploading-files-to-ibm-bluemix-object-storage-a-sample-app\\\/\"},\"wordCount\":729,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.altoros.com\\\/blog\\\/uploading-files-to-ibm-bluemix-object-storage-a-sample-app\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.altoros.com\\\/blog\\\/wp-content\\\/uploads\\\/2016\\\/04\\\/ibm-bluemix-object-storage-1.png\",\"keywords\":[\"Cloud-Native\",\"IBM Bluemix\"],\"articleSection\":[\"Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.altoros.com\\\/blog\\\/uploading-files-to-ibm-bluemix-object-storage-a-sample-app\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.altoros.com\\\/blog\\\/uploading-files-to-ibm-bluemix-object-storage-a-sample-app\\\/\",\"url\":\"https:\\\/\\\/www.altoros.com\\\/blog\\\/uploading-files-to-ibm-bluemix-object-storage-a-sample-app\\\/\",\"name\":\"Uploading Files to IBM Bluemix Object Storage: A Sample App | Altoros\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.altoros.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.altoros.com\\\/blog\\\/uploading-files-to-ibm-bluemix-object-storage-a-sample-app\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.altoros.com\\\/blog\\\/uploading-files-to-ibm-bluemix-object-storage-a-sample-app\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.altoros.com\\\/blog\\\/wp-content\\\/uploads\\\/2016\\\/04\\\/ibm-bluemix-object-storage-1.png\",\"datePublished\":\"2016-04-08T17:00:32+00:00\",\"dateModified\":\"2019-06-20T01:00:17+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.altoros.com\\\/blog\\\/#\\\/schema\\\/person\\\/3bfa3cc42526eb3e6a83df9d634e43f7\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.altoros.com\\\/blog\\\/uploading-files-to-ibm-bluemix-object-storage-a-sample-app\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.altoros.com\\\/blog\\\/uploading-files-to-ibm-bluemix-object-storage-a-sample-app\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.altoros.com\\\/blog\\\/uploading-files-to-ibm-bluemix-object-storage-a-sample-app\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.altoros.com\\\/blog\\\/wp-content\\\/uploads\\\/2016\\\/04\\\/ibm-bluemix-object-storage-1.png\",\"contentUrl\":\"https:\\\/\\\/www.altoros.com\\\/blog\\\/wp-content\\\/uploads\\\/2016\\\/04\\\/ibm-bluemix-object-storage-1.png\",\"width\":616,\"height\":364},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.altoros.com\\\/blog\\\/uploading-files-to-ibm-bluemix-object-storage-a-sample-app\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.altoros.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Uploading Files to IBM Bluemix Object Storage: A Sample App\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.altoros.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.altoros.com\\\/blog\\\/\",\"name\":\"Altoros\",\"description\":\"Insight\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.altoros.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.altoros.com\\\/blog\\\/#\\\/schema\\\/person\\\/3bfa3cc42526eb3e6a83df9d634e43f7\",\"name\":\"Gast\u00f3n Ramos\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/85463eb4f2e4baa47ff7b07e41111397f7bb0edb3dbeb78985e2e7a2ff07a0ac?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/85463eb4f2e4baa47ff7b07e41111397f7bb0edb3dbeb78985e2e7a2ff07a0ac?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/85463eb4f2e4baa47ff7b07e41111397f7bb0edb3dbeb78985e2e7a2ff07a0ac?s=96&d=mm&r=g\",\"caption\":\"Gast\u00f3n Ramos\"},\"description\":\"Gaston Ramos is a software engineer at Altoros. He specializes in Ruby on Rails as well as the Rack, Cuba, and Sinatra frameworks. Gaston started using Ruby in 2005. Since then, he enjoys a simple and clear style for writing software.\",\"url\":\"https:\\\/\\\/www.altoros.com\\\/blog\\\/author\\\/gaston-ramos\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Uploading Files to IBM Bluemix Object Storage: A Sample App | Altoros","description":"The service from IBM can serve as an alternative to AWS S3.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.altoros.com\/blog\/uploading-files-to-ibm-bluemix-object-storage-a-sample-app\/","og_locale":"en_US","og_type":"article","og_title":"Uploading Files to IBM Bluemix Object Storage: A Sample App | Altoros","og_description":"Saving objects on Bluemix Imagine that you need to deploy an application to a PaaS and this application should allow for uploading files to the server. In such scenario, you cannot just use the local storage of the application container, because it is ephemeral. This post shows you how to solve the [...]","og_url":"https:\/\/www.altoros.com\/blog\/uploading-files-to-ibm-bluemix-object-storage-a-sample-app\/","og_site_name":"Altoros","article_published_time":"2016-04-08T17:00:32+00:00","article_modified_time":"2019-06-20T01:00:17+00:00","og_image":[{"width":616,"height":364,"url":"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2016\/04\/ibm-bluemix-object-storage-1.png","type":"image\/png"}],"author":"Gast\u00f3n Ramos","twitter_misc":{"Written by":"Gast\u00f3n Ramos","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.altoros.com\/blog\/uploading-files-to-ibm-bluemix-object-storage-a-sample-app\/#article","isPartOf":{"@id":"https:\/\/www.altoros.com\/blog\/uploading-files-to-ibm-bluemix-object-storage-a-sample-app\/"},"author":{"name":"Gast\u00f3n Ramos","@id":"https:\/\/www.altoros.com\/blog\/#\/schema\/person\/3bfa3cc42526eb3e6a83df9d634e43f7"},"headline":"Uploading Files to IBM Bluemix Object Storage: A Sample App","datePublished":"2016-04-08T17:00:32+00:00","dateModified":"2019-06-20T01:00:17+00:00","mainEntityOfPage":{"@id":"https:\/\/www.altoros.com\/blog\/uploading-files-to-ibm-bluemix-object-storage-a-sample-app\/"},"wordCount":729,"commentCount":0,"image":{"@id":"https:\/\/www.altoros.com\/blog\/uploading-files-to-ibm-bluemix-object-storage-a-sample-app\/#primaryimage"},"thumbnailUrl":"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2016\/04\/ibm-bluemix-object-storage-1.png","keywords":["Cloud-Native","IBM Bluemix"],"articleSection":["Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.altoros.com\/blog\/uploading-files-to-ibm-bluemix-object-storage-a-sample-app\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.altoros.com\/blog\/uploading-files-to-ibm-bluemix-object-storage-a-sample-app\/","url":"https:\/\/www.altoros.com\/blog\/uploading-files-to-ibm-bluemix-object-storage-a-sample-app\/","name":"Uploading Files to IBM Bluemix Object Storage: A Sample App | Altoros","isPartOf":{"@id":"https:\/\/www.altoros.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.altoros.com\/blog\/uploading-files-to-ibm-bluemix-object-storage-a-sample-app\/#primaryimage"},"image":{"@id":"https:\/\/www.altoros.com\/blog\/uploading-files-to-ibm-bluemix-object-storage-a-sample-app\/#primaryimage"},"thumbnailUrl":"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2016\/04\/ibm-bluemix-object-storage-1.png","datePublished":"2016-04-08T17:00:32+00:00","dateModified":"2019-06-20T01:00:17+00:00","author":{"@id":"https:\/\/www.altoros.com\/blog\/#\/schema\/person\/3bfa3cc42526eb3e6a83df9d634e43f7"},"breadcrumb":{"@id":"https:\/\/www.altoros.com\/blog\/uploading-files-to-ibm-bluemix-object-storage-a-sample-app\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.altoros.com\/blog\/uploading-files-to-ibm-bluemix-object-storage-a-sample-app\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.altoros.com\/blog\/uploading-files-to-ibm-bluemix-object-storage-a-sample-app\/#primaryimage","url":"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2016\/04\/ibm-bluemix-object-storage-1.png","contentUrl":"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2016\/04\/ibm-bluemix-object-storage-1.png","width":616,"height":364},{"@type":"BreadcrumbList","@id":"https:\/\/www.altoros.com\/blog\/uploading-files-to-ibm-bluemix-object-storage-a-sample-app\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.altoros.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Uploading Files to IBM Bluemix Object Storage: A Sample App"}]},{"@type":"WebSite","@id":"https:\/\/www.altoros.com\/blog\/#website","url":"https:\/\/www.altoros.com\/blog\/","name":"Altoros","description":"Insight","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.altoros.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.altoros.com\/blog\/#\/schema\/person\/3bfa3cc42526eb3e6a83df9d634e43f7","name":"Gast\u00f3n Ramos","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/85463eb4f2e4baa47ff7b07e41111397f7bb0edb3dbeb78985e2e7a2ff07a0ac?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/85463eb4f2e4baa47ff7b07e41111397f7bb0edb3dbeb78985e2e7a2ff07a0ac?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/85463eb4f2e4baa47ff7b07e41111397f7bb0edb3dbeb78985e2e7a2ff07a0ac?s=96&d=mm&r=g","caption":"Gast\u00f3n Ramos"},"description":"Gaston Ramos is a software engineer at Altoros. He specializes in Ruby on Rails as well as the Rack, Cuba, and Sinatra frameworks. Gaston started using Ruby in 2005. Since then, he enjoys a simple and clear style for writing software.","url":"https:\/\/www.altoros.com\/blog\/author\/gaston-ramos\/"}]}},"_links":{"self":[{"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/posts\/19135","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/users\/65"}],"replies":[{"embeddable":true,"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/comments?post=19135"}],"version-history":[{"count":12,"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/posts\/19135\/revisions"}],"predecessor-version":[{"id":44470,"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/posts\/19135\/revisions\/44470"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/media\/19220"}],"wp:attachment":[{"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/media?parent=19135"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/categories?post=19135"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/tags?post=19135"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}