UpMyPics [By Zehaha]

    Publicités

Users Who Are Viewing This Thread (Total: 0, Members: 0, Guests: 0)

Status
Not open for further replies.

zehaha

Membre actif
Nov 28, 2010
347
0
752
Sur mon canapé
Hi !
Ca fais un bout de temps que je passe très rarement sur le forum, mais hier un pote m'as demandé de coder un truc... Et je voudrais le partager avec vous !

UpMyPics, c'est quoi?

-Un logiciel (entièrement portable), très léger (164,5 ko), gratuit (évidement), permettant d'uploader facilement et rapidement vos images sur imgur.com (pour moi le meilleur site d'upload d'image, utilisé entre autre sur reddit).

UpMyPics, ça marche comment?

-Je viens de faire une rapide vidéo explicative (la qualité est mauvaise, et c'est en accéléré, mais c'est juste pour voire vite fait^^):
Ce lien n'est pas visible, veuillez vous connecter pour l'afficher. Je m'inscris!

-Le troisième bouton est également une rapide explication, jetez-y un coup d’oeil.

Détail des fonctions :

-Ajout d'images à la liste via drag-n-drop
-Upload de toute la liste
-Upload d'une image (clic droit...)
-Idem pour supprimer la liste, soit tout soit un seul.
-C'est tout, c'est léger, c'est rapide.

JE VEUX, où ça se télécharge?

-Ce lien n'est pas visible, veuillez vous connecter pour l'afficher. Je m'inscris!


Infos complémentaires:
Codé en VB.NET par moi-même, je peux donner le code source à toute personne ayant déjà partagée des codes (hors auto.it et autre conneries) ici (un lien sera demandé).
C'est en autre pour moi un exercice sur le drag-n-drop (pas simple du tout), et un façon de me simplifier la vie^^'
 
Last edited:

Ben

Master Chief
V
Ancien staff
Mar 3, 2011
4,069
3
944
Un peut partout.
La blague, tu pourrais aux moins cité la personne qui a codé la partie de l'upload :
Code:
Namespace UpMyPics.ImgUrNET
    Friend Class ImgUrNET
        ' Methods
        Public Sub UploadByte(ByVal Data As Byte(), ByVal APIKey As String)
            Dim str2 As String = String.Concat(New String() { Me.URLEncode("image"), "=", Me.URLEncode(Convert.ToBase64String(Data)), "&", Me.URLEncode("key"), "=", Me.URLEncode(APIKey), "&", Me.URLEncode("type"), "=", Me.URLEncode("base64") })
            Dim request As HttpWebRequest = DirectCast(WebRequest.Create("http://api.imgur.com/2/upload"), HttpWebRequest)
            request.Method = "POST"
            request.ContentType = "application/x-www-form-urlencoded"
            request.ServicePoint.Expect100Continue = False
            Dim writer As New StreamWriter(request.GetRequestStream)
            writer.Write(str2)
            writer.Close
            Dim xml As String = New StreamReader(request.GetResponse.GetResponseStream).ReadToEnd
            Me.xml = xml
            Dim document As New XmlDocument
            document.LoadXml(xml)
            Dim elementsByTagName As XmlNodeList = document.GetElementsByTagName("original")
            Me.url = elementsByTagName.ItemOf(0).InnerText
            elementsByTagName = document.GetElementsByTagName("delete_page")
            Me.del = elementsByTagName.ItemOf(0).InnerText
        End Sub

        Public Sub UploadFile(ByVal Filename As String, ByVal APIKey As String)
            Dim stream As FileStream = File.OpenRead(Filename)
            Dim array As Byte() = New Byte((CInt(stream.Length) + 1)  - 1) {}
            stream.Read(array, 0, array.Length)
            stream.Close
            Dim str2 As String = String.Concat(New String() { Me.URLEncode("image"), "=", Me.URLEncode(Convert.ToBase64String(array)), "&", Me.URLEncode("key"), "=", Me.URLEncode(APIKey), "&", Me.URLEncode("type"), "=", Me.URLEncode("base64") })
            Dim request As HttpWebRequest = DirectCast(WebRequest.Create("http://api.imgur.com/2/upload"), HttpWebRequest)
            request.Method = "POST"
            request.ContentType = "application/x-www-form-urlencoded"
            request.ServicePoint.Expect100Continue = False
            Dim writer As New StreamWriter(request.GetRequestStream)
            writer.Write(str2)
            writer.Close
            Dim xml As String = New StreamReader(request.GetResponse.GetResponseStream).ReadToEnd
            Me.xml = xml
            Dim document As New XmlDocument
            document.LoadXml(xml)
            Dim elementsByTagName As XmlNodeList = document.GetElementsByTagName("original")
            Me.url = elementsByTagName.ItemOf(0).InnerText
            elementsByTagName = document.GetElementsByTagName("delete_page")
            Me.del = elementsByTagName.ItemOf(0).InnerText
        End Sub

        Public Sub UploadURL(ByVal URL As String, ByVal APIKey As String)
            Dim str2 As String = String.Concat(New String() { Me.URLEncode("image"), "=", Me.URLEncode(URL), "&", Me.URLEncode("key"), "=", Me.URLEncode(APIKey), "&", Me.URLEncode("type"), "=", Me.URLEncode("url") })
            Dim request As HttpWebRequest = DirectCast(WebRequest.Create("http://api.imgur.com/2/upload"), HttpWebRequest)
            request.Method = "POST"
            request.ContentType = "application/x-www-form-urlencoded"
            request.ServicePoint.Expect100Continue = False
            Dim writer As New StreamWriter(request.GetRequestStream)
            writer.Write(str2)
            writer.Close
            Dim xml As String = New StreamReader(request.GetResponse.GetResponseStream).ReadToEnd
            Me.xml = xml
            Dim document As New XmlDocument
            document.LoadXml(xml)
            URL = document.GetElementsByTagName("original").ItemOf(0).InnerText
            Dim elementsByTagName As XmlNodeList = document.GetElementsByTagName("delete_page")
            Me.del = elementsByTagName.ItemOf(0).InnerText
        End Sub

        Public Function URLEncode(ByVal [Text] As String) As String
            Dim expression As String = [Text]
            Dim i As Integer = Strings.Len(expression)
            Do While (i >= 1)
                Dim number As Integer = Strings.Asc(Strings.Mid(expression, i, 1))
                Dim num3 As Integer = number
                If ((((num3 < &H30) OrElse (num3 > &H39)) AndAlso ((num3 < &H41) OrElse (num3 > 90))) AndAlso ((num3 < &H61) OrElse (num3 > &H7A))) Then
                    If (num3 = &H20) Then
                        expression = (expression.Substring(0, (i - 1)) & "+" & Strings.Mid(expression, (i + 1)))
                    Else
                        expression = (expression.Substring(0, (i - 1)) & "%" & Conversion.Hex(number) & Strings.Mid(expression, (i + 1)))
                    End If
                End If
                i = (i + -1)
            Loop
            If (Strings.InStr(expression, "%D%A", CompareMethod.Binary) > 0) Then
                expression = Strings.Replace(expression, "%D%A", "%0D%0A", 1, -1, CompareMethod.Binary)
            End If
            Return expression
        End Function
 
Mar 19, 2011
1,863
1
461
39
La blague, tu pourrais aux moins cité la personne qui a codé la partie de l'upload :
Code:
Namespace UpMyPics.ImgUrNET
    Friend Class ImgUrNET
        ' Methods
        Public Sub UploadByte(ByVal Data As Byte(), ByVal APIKey As String)
            Dim str2 As String = String.Concat(New String() { Me.URLEncode("image"), "=", Me.URLEncode(Convert.ToBase64String(Data)), "&", Me.URLEncode("key"), "=", Me.URLEncode(APIKey), "&", Me.URLEncode("type"), "=", Me.URLEncode("base64") })
            Dim request As HttpWebRequest = DirectCast(WebRequest.Create("http://api.imgur.com/2/upload"), HttpWebRequest)
            request.Method = "POST"
            request.ContentType = "application/x-www-form-urlencoded"
            request.ServicePoint.Expect100Continue = False
            Dim writer As New StreamWriter(request.GetRequestStream)
            writer.Write(str2)
            writer.Close
            Dim xml As String = New StreamReader(request.GetResponse.GetResponseStream).ReadToEnd
            Me.xml = xml
            Dim document As New XmlDocument
            document.LoadXml(xml)
            Dim elementsByTagName As XmlNodeList = document.GetElementsByTagName("original")
            Me.url = elementsByTagName.ItemOf(0).InnerText
            elementsByTagName = document.GetElementsByTagName("delete_page")
            Me.del = elementsByTagName.ItemOf(0).InnerText
        End Sub

        Public Sub UploadFile(ByVal Filename As String, ByVal APIKey As String)
            Dim stream As FileStream = File.OpenRead(Filename)
            Dim array As Byte() = New Byte((CInt(stream.Length) + 1)  - 1) {}
            stream.Read(array, 0, array.Length)
            stream.Close
            Dim str2 As String = String.Concat(New String() { Me.URLEncode("image"), "=", Me.URLEncode(Convert.ToBase64String(array)), "&", Me.URLEncode("key"), "=", Me.URLEncode(APIKey), "&", Me.URLEncode("type"), "=", Me.URLEncode("base64") })
            Dim request As HttpWebRequest = DirectCast(WebRequest.Create("http://api.imgur.com/2/upload"), HttpWebRequest)
            request.Method = "POST"
            request.ContentType = "application/x-www-form-urlencoded"
            request.ServicePoint.Expect100Continue = False
            Dim writer As New StreamWriter(request.GetRequestStream)
            writer.Write(str2)
            writer.Close
            Dim xml As String = New StreamReader(request.GetResponse.GetResponseStream).ReadToEnd
            Me.xml = xml
            Dim document As New XmlDocument
            document.LoadXml(xml)
            Dim elementsByTagName As XmlNodeList = document.GetElementsByTagName("original")
            Me.url = elementsByTagName.ItemOf(0).InnerText
            elementsByTagName = document.GetElementsByTagName("delete_page")
            Me.del = elementsByTagName.ItemOf(0).InnerText
        End Sub

        Public Sub UploadURL(ByVal URL As String, ByVal APIKey As String)
            Dim str2 As String = String.Concat(New String() { Me.URLEncode("image"), "=", Me.URLEncode(URL), "&", Me.URLEncode("key"), "=", Me.URLEncode(APIKey), "&", Me.URLEncode("type"), "=", Me.URLEncode("url") })
            Dim request As HttpWebRequest = DirectCast(WebRequest.Create("http://api.imgur.com/2/upload"), HttpWebRequest)
            request.Method = "POST"
            request.ContentType = "application/x-www-form-urlencoded"
            request.ServicePoint.Expect100Continue = False
            Dim writer As New StreamWriter(request.GetRequestStream)
            writer.Write(str2)
            writer.Close
            Dim xml As String = New StreamReader(request.GetResponse.GetResponseStream).ReadToEnd
            Me.xml = xml
            Dim document As New XmlDocument
            document.LoadXml(xml)
            URL = document.GetElementsByTagName("original").ItemOf(0).InnerText
            Dim elementsByTagName As XmlNodeList = document.GetElementsByTagName("delete_page")
            Me.del = elementsByTagName.ItemOf(0).InnerText
        End Sub

        Public Function URLEncode(ByVal [Text] As String) As String
            Dim expression As String = [Text]
            Dim i As Integer = Strings.Len(expression)
            Do While (i >= 1)
                Dim number As Integer = Strings.Asc(Strings.Mid(expression, i, 1))
                Dim num3 As Integer = number
                If ((((num3 < &H30) OrElse (num3 > &H39)) AndAlso ((num3 < &H41) OrElse (num3 > 90))) AndAlso ((num3 < &H61) OrElse (num3 > &H7A))) Then
                    If (num3 = &H20) Then
                        expression = (expression.Substring(0, (i - 1)) & "+" & Strings.Mid(expression, (i + 1)))
                    Else
                        expression = (expression.Substring(0, (i - 1)) & "%" & Conversion.Hex(number) & Strings.Mid(expression, (i + 1)))
                    End If
                End If
                i = (i + -1)
            Loop
            If (Strings.InStr(expression, "%D%A", CompareMethod.Binary) > 0) Then
                expression = Strings.Replace(expression, "%D%A", "%0D%0A", 1, -1, CompareMethod.Binary)
            End If
            Return expression
        End Function

On peut rien caché avec lui
 

Ben

Master Chief
V
Ancien staff
Mar 3, 2011
4,069
3
944
Un peut partout.
Pas dit que c'était interdit mais la façon que tu utilise est exactement la même que j'ai trouvé sur le net.

Exemple moi j'en est fait un et je n'utilise pas du tout cette méthode (beaucoup de code pour pas grand chose ta technique vue que tu utilise du .Xml)

Code:
  Dim apiKey As String = "b9b03e223918469b258194599f5ef68b"
            Dim imageData() As Byte
            Dim fileStream As FileStream = File.OpenRead(OpenFileDialog1.FileName)
            imageData = New Byte((fileStream.Length) - 1) {}
            fileStream.Read(imageData, 0, imageData.Length)
            fileStream.Close()
            Dim uploadRequestString As String = HttpUtility.UrlEncode("image", Encoding.UTF8) + "=" + HttpUtility.UrlEncode(System.Convert.ToBase64String(imageData)) + "&" + HttpUtility.UrlEncode("key", Encoding.UTF8) + "=" + HttpUtility.UrlEncode(apiKey, Encoding.UTF8)
            Dim webRequest As HttpWebRequest = CType(Net.WebRequest.Create("http://api.imgur.com/2/upload"), HttpWebRequest)
            webRequest.Method = "POST"
            webRequest.ContentType = "application/x-www-form-urlencoded"
            webRequest.ServicePoint.Expect100Continue = False
            Dim streamWriter As IO.StreamWriter = New IO.StreamWriter(webRequest.GetRequestStream)
            streamWriter.Write(uploadRequestString)
            streamWriter.Close()
            Dim response As WebResponse = webRequest.GetResponse
            Dim responseStream As Stream = response.GetResponseStream
            Dim responseReader As StreamReader = New StreamReader(responseStream)
            Dim responseString As String = responseReader.ReadToEnd
            Dim ImageURL As String = Split(responseString, "<original>")(1).Split("<")(0)
 

zehaha

Membre actif
Nov 28, 2010
347
0
752
Sur mon canapé
Pas dit que c'était interdit mais la façon que tu utilise est exactement la même que j'ai trouvé sur le net.

Exemple moi j'en est fait un et je n'utilise pas du tout cette méthode (beaucoup de code pour pas grand chose ta technique vue que tu utilise du .Xml)

Code:
  Dim apiKey As String = "b9b03e223918469b258194599f5ef68b"
            Dim imageData() As Byte
            Dim fileStream As FileStream = File.OpenRead(OpenFileDialog1.FileName)
            imageData = New Byte((fileStream.Length) - 1) {}
            fileStream.Read(imageData, 0, imageData.Length)
            fileStream.Close()
            Dim uploadRequestString As String = HttpUtility.UrlEncode("image", Encoding.UTF8) + "=" + HttpUtility.UrlEncode(System.Convert.ToBase64String(imageData)) + "&" + HttpUtility.UrlEncode("key", Encoding.UTF8) + "=" + HttpUtility.UrlEncode(apiKey, Encoding.UTF8)
            Dim webRequest As HttpWebRequest = CType(Net.WebRequest.Create("http://api.imgur.com/2/upload"), HttpWebRequest)
            webRequest.Method = "POST"
            webRequest.ContentType = "application/x-www-form-urlencoded"
            webRequest.ServicePoint.Expect100Continue = False
            Dim streamWriter As IO.StreamWriter = New IO.StreamWriter(webRequest.GetRequestStream)
            streamWriter.Write(uploadRequestString)
            streamWriter.Close()
            Dim response As WebResponse = webRequest.GetResponse
            Dim responseStream As Stream = response.GetResponseStream
            Dim responseReader As StreamReader = New StreamReader(responseStream)
            Dim responseString As String = responseReader.ReadToEnd
            Dim ImageURL As String = Split(responseString, "<original>")(1).Split("<")(0)

Bah celui chez qui tu as trouvé ça à lui même leech sur l'API ;)
 
Status
Not open for further replies.