".gif", _
".png"}
+ Private Const MaxFileSize As Long = 5 * 1024 * 1024
+
Public Function Upload(ByVal mediaFile As FileInfo, _
ByVal message As String, _
ByRef content As String) As HttpStatusCode
If String.IsNullOrEmpty(message) Then message = ""
'Check filetype and size(Max 5MB)
If Array.IndexOf(pictureExt, mediaFile.Extension.ToLower) > -1 Then
- If mediaFile.Length > 5242880 Then Throw New ArgumentException("File is too large.")
+ If mediaFile.Length > MaxFileSize Then Throw New ArgumentException("File is too large.")
Else
Throw New ArgumentException("Service don't support this filetype.")
End If
Return type.Equals(UploadFileType.Picture)
End Function
+ Public Function GetMaxFileSize(ByVal ext As String) As Long
+ If Array.IndexOf(pictureExt, ext.ToLower) > -1 Then
+ Return MaxFileSize
+ End If
+ Return -1
+ End Function
+
Public Sub New(ByVal accessToken As String, ByVal accessTokenSecret As String)
MyBase.New(New Uri("http://api.twitter.com/"), _
New Uri("https://api.twitter.com/1/account/verify_credentials.json"))
".gif", _
".png"}
+ Private Const MaxPictureFileSize As Long = 10 * 1024 * 1024
+ Private Const MaxMultiMediaFileSize As Long = 20 * 1024 * 1024
+
Public Function Upload(ByVal mediaFile As FileInfo, _
ByVal message As String, _
ByVal keyword As String, _
If String.IsNullOrEmpty(message) Then Throw New ArgumentException("'Message' is required.")
'Check filetype and size
If Array.IndexOf(multimediaExt, mediaFile.Extension.ToLower) > -1 Then
- If mediaFile.Length > 20971520 Then Throw New ArgumentException("File is too large.")
+ If mediaFile.Length > MaxMultiMediaFileSize Then Throw New ArgumentException("File is too large.")
ElseIf Array.IndexOf(pictureExt, mediaFile.Extension.ToLower) > -1 Then
- If mediaFile.Length > 10485760 Then Throw New ArgumentException("File is too large.")
+ If mediaFile.Length > MaxPictureFileSize Then Throw New ArgumentException("File is too large.")
Else
Throw New ArgumentException("Service don't support this filetype.")
End If
Return type.Equals(UploadFileType.Picture) OrElse type.Equals(UploadFileType.MultiMedia)
End Function
+ Public Function GetMaxFileSize(ByVal ext As String) As Long
+ If Array.IndexOf(multimediaExt, ext.ToLower) > -1 Then
+ Return MaxMultiMediaFileSize
+ ElseIf Array.IndexOf(pictureExt, ext.ToLower) > -1 Then
+ Return MaxPictureFileSize
+ End If
+ Return -1
+ End Function
+
Public Function GetFileOpenDialogFilter() As String
Return "Image Files(*.gif;*.jpg;*.jpeg;*.png)|*.gif;*.jpg;*.jpeg;*.png|" + _
"Movie Files(*.avi;*.wmv;*.flv;*.m4v;*.mov;*.mp4;*.rm;*.mpeg;*.mpg;*.3gp;*.3g2)|*.avi;*.wmv;*.flv;*.m4v;*.mov;*.mp4;*.rm;*.mpeg;*.mpg;*.3gp;*.3g2"
".gif", _
".png"}
+ Private Const MaxFileSize As Long = 4 * 1024 * 1024
+
Public Function Upload(ByVal mediaFile As FileInfo, _
ByVal message As String, _
ByRef content As String) As HttpStatusCode
If String.IsNullOrEmpty(message) Then message = ""
'Check filetype and size(Max 4MB)
If Array.IndexOf(pictureExt, mediaFile.Extension.ToLower) > -1 Then
- If mediaFile.Length > 4 * 1024 * 1024 Then Throw New ArgumentException("File is too large.")
+ If mediaFile.Length > MaxFileSize Then Throw New ArgumentException("File is too large.")
Else
Throw New ArgumentException("Service don't support this filetype.")
End If
Return type.Equals(UploadFileType.Picture)
End Function
+ Public Function GetMaxFileSize(ByVal ext As String) As Long
+ If Array.IndexOf(pictureExt, ext.ToLower) > -1 Then
+ Return MaxFileSize
+ End If
+ Return -1
+ End Function
+
Public Sub New(ByVal accessToken As String, ByVal accessTokenSecret As String)
MyBase.New(New Uri("http://api.twitter.com/"), _
New Uri("https://api.twitter.com/1/account/verify_credentials.json"))
Return ret
End Function
+ Public Function GetMaxFileSize(ByVal ext As String, ByVal service As String) As Long
+ Dim ret As Long = -1
+ Select Case service
+ Case "TwitPic"
+ ret = (New TwitPic(tw.AccessToken, tw.AccessTokenSecret)).GetMaxFileSize(ext)
+ Case "img.ly"
+ ret = (New imgly(tw.AccessToken, tw.AccessTokenSecret)).GetMaxFileSize(ext)
+ Case "TwitVideo"
+ ret = (New TwitVideo).GetMaxFileSize(ext)
+ End Select
+ Return ret
+ End Function
+
Private Function UpToTwitPic(ByVal file As FileInfo, ByRef message As String, ByVal resultUpload As Boolean) As String
Dim content As String = ""
Dim ret As HttpStatusCode
* 詳細表示でCtrl+Insertキーでもコピーができるようにした
* 画像投稿モードで使用する画像リソースを差し替えた また、動画をドラッグした場合は専用の画像を表示するようにした(thx @pureminami)
* 読み上げソフトで問題が出ないように調整を行った
+ * 画像投稿モードでファイルを設定した際にファイルサイズチェックを行うようにした
+ * 画像投稿モードで無効なファイル形式を設定した場合にファイル名がクリアされない場合があるバグを修正
==== Ver 0.9.4.0(2010/07/15)
* 認証完了後、自分の発言が片思い表示になるバグ修正
* ユーザー変更時にフォロワー情報を取得するよう変更
If String.IsNullOrEmpty(Trim(ImagefilePathText.Text)) Then
ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
ImageSelectedPicture.Tag = UploadFileType.Invalid
+ ImagefilePathText.Text = ""
Exit Sub
End If
'画像以外の形式
ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
ImageSelectedPicture.Tag = UploadFileType.Invalid
+ ImagefilePathText.Text = ""
+ Exit Sub
+ End If
+
+ If svc.GetMaxFileSize(fl.Extension, ImageService) < fl.Length Then
+ ' ファイルサイズが大きすぎる
+ ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
+ ImageSelectedPicture.Tag = UploadFileType.Invalid
+ ImagefilePathText.Text = ""
+ MessageBox.Show("File is too large.")
Exit Sub
End If
Case UploadFileType.Invalid
ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
ImageSelectedPicture.Tag = UploadFileType.Invalid
+ ImagefilePathText.Text = ""
Case UploadFileType.Picture
Using fs As New FileStream(ImagefilePathText.Text, FileMode.Open, FileAccess.Read)
ImageSelectedPicture.Image = (New HttpVarious).CheckValidImage( _
End Using
ImageSelectedPicture.Tag = UploadFileType.Picture
Case UploadFileType.MultiMedia
- ''' TODO:動画アップロード用画像へ変更
ImageSelectedPicture.Image = My.Resources.MultiMediaImage
ImageSelectedPicture.Tag = UploadFileType.MultiMedia
Case Else
ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
ImageSelectedPicture.Tag = UploadFileType.Invalid
+ ImagefilePathText.Text = ""
End Select
Catch ex As FileNotFoundException
ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
ImageSelectedPicture.Tag = UploadFileType.Invalid
+ ImagefilePathText.Text = ""
MessageBox.Show("File not found.")
Catch ex As Exception
ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
ImageSelectedPicture.Tag = UploadFileType.Invalid
+ ImagefilePathText.Text = ""
MessageBox.Show("The type of this file is not image.")
End Try
End Sub