diff --git a/app/models/learning_object/attachment.rb b/app/models/learning_object/attachment.rb
index ddf7b9c4910ff207638f6de7d228564609a46445..ea56409fb23fc440979596d73ec999df7d6eadca 100644
--- a/app/models/learning_object/attachment.rb
+++ b/app/models/learning_object/attachment.rb
@@ -18,7 +18,7 @@ class LearningObject::Attachment
   def get_bitstream_retrievelink_of name
     values = @bitstreams.select { |v| v["bundleName"] == name }
     unless values.empty?
-      return Dspace::Config.rest_url + values.first["retrieveLink"]
+      return "#{DspaceService.link}#{values.first["retrieveLink"]}"
     end
   end
 
@@ -29,4 +29,4 @@ class LearningObject::Attachment
     end
   end
 
-end
\ No newline at end of file
+end
diff --git a/app/services/dspace_service.rb b/app/services/dspace_service.rb
index 10ff5433cdae7c07ed95b347c821f7da61aa1dca..59610a7e8ad43710e89c6470ebce3d561cc484f0 100644
--- a/app/services/dspace_service.rb
+++ b/app/services/dspace_service.rb
@@ -1,19 +1,37 @@
 class DspaceService
+  @config = nil
+
   def self.create_client
-    if Rails.env.production?
-      link = "https://#{ENV['PORTALMEC_DSPACE_HOST']}:#{ENV['PORTALMEC_DSPACE_PORT']}"
-      login = ENV['PORTALMEC_DSPACE_LOGIN']
-      password = ENV['PORTALMEC_DSPACE_PASSWORD']
-    else
-      dspace_configs = YAML.load_file(Rails.root.join('config').to_s.concat('/dspace.yml'))
-      config = dspace_configs.fetch(Rails.env)
+    config
 
-      link = "#{config['host']}:#{config['port']}"
-      login = config['login']
-      password = config['password']
-    end
+    dspace_client = Dspace::Client.new(dspace_api: @config['link'])
+    dspace_client.login @config['login'], @config['password']
+  end
 
-    dspace_client = Dspace::Client.new(dspace_api: link)
-    dspace_client.login login, password
+  def self.link
+    config
+
+    @config['link']
+  end
+
+  private
+
+  def self.config
+    if @config.nil?
+      @config = {}
+      
+      if Rails.env.production?
+        @config['link'] = "https://#{ENV['PORTALMEC_DSPACE_HOST']}:#{ENV['PORTALMEC_DSPACE_PORT']}"
+        @config['login'] = ENV['PORTALMEC_DSPACE_LOGIN']
+        @config['password'] = ENV['PORTALMEC_DSPACE_PASSWORD']
+      else
+        yml_file = YAML.load_file(Rails.root.join('config').to_s.concat('/dspace.yml'))
+        yml = yml_file.fetch(Rails.env)
+
+        @config['link'] = "https://#{yml['host']}:#{yml['port']}"
+        @config['login'] = yml['login']
+        @config['password'] = yml['password']
+      end
+    end
   end
 end