Class: Sorenson::ThreeSixty::Uploader

Inherits:
Base
  • Object
show all
Defined in:
lib/sorenson/threesixty/uploader.rb

Constant Summary

Constants inherited from Base

Base::TOKEN_SALT

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

debug=, debug?, host, #post_to, post_to, protocol, token_for, use_ssl=, use_ssl?

Constructor Details

#initialize(account, options = {}) ⇒ Uploader

Instance Methods



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/sorenson/threesixty/uploader.rb', line 11

def initialize(, options = {})
  self. = 
  defaults = {
    'application' => 'Unknown',
    'frameRate'   => '1:1',
    'width'       => 320,
    'height'      => 240,
    'audioDataRate'  => '19000',
    'videoDataRate'  => '23222',
    'audioBitRateMode' => 'VBR_STEREO',
    'videoBitRateMode' => 'VBR_TWO_PASS',
    'videoDuration'    => 0,
    'fileType'         => 'Flash',
    'audioCodec' => 'unknown',
    'videoCodec' => 'unknown',
    'authorName' => 'unknown',
    'sourceFileName' => 'unknown',
    'sourceAudioCodec' => 'unknown',
    'sourceVideoCodec' => 'unknown',
    'sourceFrameRate' => '1:1',
    'sourceWidth' => 0,
    'sourceHeight' => 0,
    'sourceAudioBitRateMode' => 'unknown',
    'sourceVideoDataRate' => '23222',
    'sourceVideoBitRateMode' => 'unknown'
  }

  attributes = defaults.merge(options)
  
  attributes.each do |k,v|
    method = "#{k}=".to_sym
    self.send(method, v) if self.respond_to?(method)
  end
end

Instance Attribute Details

#accountObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/uploader.rb', line 6

def 
  @account
end

#applicationObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/uploader.rb', line 6

def application
  @application
end

#audioBitRateModeObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/uploader.rb', line 6

def audioBitRateMode
  @audioBitRateMode
end

#audioCodecObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/uploader.rb', line 6

def audioCodec
  @audioCodec
end

#audioDataRateObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/uploader.rb', line 6

def audioDataRate
  @audioDataRate
end

#authorNameObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/uploader.rb', line 6

def authorName
  @authorName
end

#descriptionObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/uploader.rb', line 6

def description
  @description
end

#displayNameObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/uploader.rb', line 6

def displayName
  @displayName
end

#fileTypeObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/uploader.rb', line 6

def fileType
  @fileType
end

#filterObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/uploader.rb', line 6

def filter
  @filter
end

#frameRateObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/uploader.rb', line 6

def frameRate
  @frameRate
end

#heightObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/uploader.rb', line 6

def height
  @height
end

#pathToAssetObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/uploader.rb', line 6

def pathToAsset
  @pathToAsset
end

#pathToMainThumbnailObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/uploader.rb', line 6

def pathToMainThumbnail
  @pathToMainThumbnail
end

#pathToShortPreviewObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/uploader.rb', line 6

def pathToShortPreview
  @pathToShortPreview
end

#pathToSummaryThumbnailsObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/uploader.rb', line 6

def pathToSummaryThumbnails
  @pathToSummaryThumbnails
end

#presetXMLObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/uploader.rb', line 6

def presetXML
  @presetXML
end

#sourceAudioBitRateModeObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/uploader.rb', line 6

def sourceAudioBitRateMode
  @sourceAudioBitRateMode
end

#sourceAudioCodecObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/uploader.rb', line 6

def sourceAudioCodec
  @sourceAudioCodec
end

#sourceAudioDataRateObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/uploader.rb', line 6

def sourceAudioDataRate
  @sourceAudioDataRate
end

#sourceFileNameObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/uploader.rb', line 6

def sourceFileName
  @sourceFileName
end

#sourceFileTypeObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/uploader.rb', line 6

def sourceFileType
  @sourceFileType
end

#sourceFrameRateObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/uploader.rb', line 6

def sourceFrameRate
  @sourceFrameRate
end

#sourceHeightObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/uploader.rb', line 6

def sourceHeight
  @sourceHeight
end

#sourceVideoBitRateModeObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/uploader.rb', line 6

def sourceVideoBitRateMode
  @sourceVideoBitRateMode
end

#sourceVideoCodecObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/uploader.rb', line 6

def sourceVideoCodec
  @sourceVideoCodec
end

#sourceVideoDataRateObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/uploader.rb', line 6

def sourceVideoDataRate
  @sourceVideoDataRate
end

#sourceWidthObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/uploader.rb', line 6

def sourceWidth
  @sourceWidth
end

#videoBitRateModeObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/uploader.rb', line 6

def videoBitRateMode
  @videoBitRateMode
end

#videoCodecObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/uploader.rb', line 6

def videoCodec
  @videoCodec
end

#videoDataRateObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/uploader.rb', line 6

def videoDataRate
  @videoDataRate
end

#videoDurationObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/uploader.rb', line 6

def videoDuration
  @videoDuration
end

#widthObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/uploader.rb', line 6

def width
  @width
end

Instance Method Details

#getMD5HashObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/sorenson/threesixty/uploader.rb', line 46

def getMD5Hash
  md5 = Digest::MD5.new

  return false unless File.exist?(pathToAsset)

  length = File.size(pathToAsset)
  fp = File.open(pathToAsset)

  totalRead = 0
  numRead = 0

  numSamples = 100
  sampleSize = 1024
  bytes = 1024
  
  puts length
  puts numSamples * sampleSize
  # 
  # if (length <= numSamples * sampleSize)
  #   while (totalRead < length)
  #     totalRead += bytes
  #     data = fp.read(bytes)
  #     md5.update(data);
  #   end
  # else
  #   skipBlockSize = length / numSamples - sampleSize
  # 
  #   long skipBlockSize = length / numSamples - sampleSize;
  # 
  #   while (length - totalRead > sampleSize + skipBlockSize)
  #   {
  #       numRead = 0;
  # 
  #       while (numRead < sampleSize)
  #       {
  #           numRead = is.read(bytes, 0, Math.min(bytes.length, sampleSize - numRead));
  #           md5.update(bytes, 0, numRead);
  #           totalRead += numRead;
  #       }
  # 
  #       is.skip(skipBlockSize);
  #       totalRead += skipBlockSize;
  #   }
  #   
  # 
  # end

  md5.hexdigest
end

#uploadAssetObject



96
97
98
99
100
101
102
103
104
105
106
# File 'lib/sorenson/threesixty/uploader.rb', line 96

def uploadAsset
  # url = URI.parse('http://www.example.com/upload')
  #         File.open("./image.jpg") do |jpg|
  #           req = Net::HTTP::Post::Multipart.new url.path,
  #             "file" => UploadIO.new(jpg, "image/jpeg", "image.jpg")
  #           res = Net::HTTP.start(url.host, url.port) do |http|
  #             http.request(req)
  #           end
  #         end
  #         
end