Created
December 10, 2013 20:08
-
-
Save jcutrell/7897323 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@clip_object.clips.each_with_index do |clip, i| | |
# puts clip[:video][:media_url] | |
gcdq = Dispatch::Queue.concurrent(:high) | |
gcdq.async { | |
# por = S3PutObjectRequest.alloc.initWithKey(clip[:aws_path], inBucket:"southtree_dvds") | |
# por.contentType = "video/mp4" | |
# por.filename = clip[:video][:media_url].to_s | |
asset_url = clip[:video][:reference_url] | |
assets_library.assetForURL(asset_url, resultBlock: lambda { |asset| | |
# clip[:raw_data] = rawData | |
# por.data = rawData | |
# por.requestTag = "clip-#{i}" | |
# putObjectResponse = @s3client.putObject(por) | |
# initiateMultipartUpload:(S3InitiateMultipartUploadRequest *)initiateMultipartUploadRequest | |
selectedAsset = asset | |
### TODO: Loop through the data and perform multipart uploads to avoid allocating large chunks. | |
offset = 0 | |
i = 1 | |
incomplete = true | |
mpul = s3client.initiateMultipartUploadWithKey(clip[:aws_path], withBucket:"southtree_dvds") | |
complete = S3CompleteMultipartUploadRequest.alloc.initWithMultipartUpload(mpul) | |
while incomplete do | |
uploadPartReq = S3UploadPartRequest.alloc.initWithMultipartUpload(mpul) | |
uploadPartReq.uploadId = mpul.uploadId | |
uploadPartReq.data = getDataPartAtOffset(selectedAsset.defaultRepresentation, offset) | |
puts uploadPartReq.data.length | |
if ( !uploadPartReq.data || uploadPartReq.data.length==0 ) | |
incomplete = false | |
# completed = s3client.completeMultipartUpload(complete) | |
else | |
uploadPartReq.partNumber = i | |
uploadPartReq.delegate = self | |
uploadPart = s3client.uploadPart uploadPartReq | |
# puts uploadPart | |
# complete.addPartWithPartNumber(i, withETag:uploadPart.etag) | |
offset+=uploadPartReq.data.length | |
i+=1 | |
end | |
end | |
# rawData = NSMutableData.alloc.initWithCapacity(byteArraySize) | |
# bufferPointer = rawData.mutableBytes | |
# error = Pointer.new(:object) | |
# selectedAsset.defaultRepresentation.getBytes(bufferPointer, fromOffset:0, length:byteArraySize, error:error) | |
# rawData = NSMutableData.dataWithBytes(bufferPointer, length:byteArraySize) | |
completion_block.call(nil) if block_given? | |
}, failureBlock: lambda {|error| | |
}) | |
# por.data = clip[:video][:original_image] | |
# @complete_clip_uploads = @complete_clip_uploads + 1 | |
# @dvd.upload_progress = @complete_clip_uploads/totalclips | |
# if @complete_clip_uploads == totalclips | |
# @dvd.upload_operation.start | |
# end | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment