diff --git a/app/controllers/v1/learning_objects/chunks_controller.rb b/app/controllers/v1/learning_objects/chunks_controller.rb index 451300fe1569b2acd1e813f58fc7ab357c73b388..fcc4521aefe58ddfab266908705e97134c9f693c 100644 --- a/app/controllers/v1/learning_objects/chunks_controller.rb +++ b/app/controllers/v1/learning_objects/chunks_controller.rb @@ -59,12 +59,26 @@ class V1::LearningObjects::ChunksController < ApplicationController params.permit(:id, :file, :_chunkNumber, :_totalChunks, :_chunkFilename, :_chunkIdentifier, :_chunkSize, :_currentChunkSize, :_totalSize, :cancel) end + # def post_file! + # attachment = @learning_object.attachments.create(name: File.basename(final_file_path), retrieve_link: final_file_path, bundle_name: "TEMP") + # publisher = LearningObjectPublisher.new(DspaceService.create_client) + # publisher.upload @learning_object, final_file_path, attachment + # end + def post_file! attachment = @learning_object.attachments.create(name: File.basename(final_file_path), retrieve_link: final_file_path, bundle_name: "TEMP") - publisher = LearningObjectPublisher.new(DspaceService.create_client) - publisher.upload @learning_object, final_file_path, attachment + file = open(final_file_path) + data=file.read + s3_client = Aws::S3::Client.new + s3_client.put_object( + key: (@learning_object.id).to_s, + body: data, + bucket: "portalmecs3", + content_type: 'text/plain' + ) end + ## # Move the temporary Sinatra upload to the chunk file location def save_file! @@ -88,7 +102,7 @@ class V1::LearningObjects::ChunksController < ApplicationController f.write File.read(file_chunk_path) end end - FileUtils.chown_R 'portalmec', 'portalmec', final_file_path + # FileUtils.chown_R 'portalmec', 'portalmec', final_file_path FileUtils.chmod 0644, final_file_path # Cleanup chunk file directory and all chunk files FileUtils.rm_rf(chunk_file_directory) diff --git a/app/serializers/user_serializer.rb b/app/serializers/user_serializer.rb index 0ff26d06b7b6287a44766184641c439c03fe7074..fa0f3dd22806b6a8a6a0b141fa98ef401633470a 100644 --- a/app/serializers/user_serializer.rb +++ b/app/serializers/user_serializer.rb @@ -111,7 +111,6 @@ class UserSerializer < ActiveModel::Serializer :experience, :points, :last_action_at, - :streak, :high_streak attribute \ diff --git a/app/services/dspace_service.rb b/app/services/dspace_service.rb index cac09e7e692316c5b7143cc9bc391b1707717f81..529ec862cd04cc8bdd43dfa44735ad69ccd850fe 100644 --- a/app/services/dspace_service.rb +++ b/app/services/dspace_service.rb @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -require 'dspace' +#require 'dspace' class DspaceService diff --git a/app/services/s3/aws.rb b/app/services/s3/aws.rb deleted file mode 100644 index 4708b8311206b42b1bb383d1a9447d748aa1de62..0000000000000000000000000000000000000000 --- a/app/services/s3/aws.rb +++ /dev/null @@ -1,47 +0,0 @@ - -require 'aws-sdk-s3' -require "json" - -Aws.config.update( - endpoint: 'https://s3.c3sl.ufpr.br', - access_key_id: ' GMHK6OO49J0FT1ZC5EPT', - secret_access_key: 'MyknbDcne4JRNCi6GJhDsSaH3No4TpdCzIjwcJ0K', - force_path_style: true, - region: 'default', -) - -bucket_name = "portalmecs3" - -s3_client = Aws::S3::Client.new - -file = open("/home/des20/hello.txt") -file_data = file.read - -s3_client.put_object( - key: 'hello.txt', - body: file_data, - bucket: bucket_name, - content_type: 'text/plain' -) - -object=s3_client.get_object( - key: 'hello.txt', - bucket: 'portalmecs3', -) -puts object.body.read - -# wrapper = Aws::S3::Object.new(bucket_name, 'hello.txt') -# obj_data = wrapper.getObjectContent -# puts obj_data - -# s3_client.delete_object( -# key: 'hello.txt', -# bucket: 'portalmecs3', -# ) - -# buckets = s3_client.list_buckets - -# puts 'List of S3 buckets:' -# buckets.each do |bucket| -# puts {bucket.name}\t{bucket.creation_date} -# end \ No newline at end of file diff --git a/config/initializers/aws.rb b/config/initializers/aws.rb new file mode 100644 index 0000000000000000000000000000000000000000..9d41773637739c6c8efe40e0fdb06e91ab5d1c87 --- /dev/null +++ b/config/initializers/aws.rb @@ -0,0 +1,25 @@ +# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre +# Departamento de Informatica - Universidade Federal do Parana +# +# This file is part of portalmec. +# +# portalmec is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# portalmec is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with portalmec. If not, see <http://www.gnu.org/licenses/>. + +Aws.config.update( + endpoint: 'https://s3.c3sl.ufpr.br', + access_key_id: ' GMHK6OO49J0FT1ZC5EPT', + secret_access_key: 'MyknbDcne4JRNCi6GJhDsSaH3No4TpdCzIjwcJ0K', + force_path_style: true, + region: 'default', + ) \ No newline at end of file