Skip to content
jamesheck2019 edited this page Jan 15, 2020 · 15 revisions

MediafireSDK

Download:https://github.com/jamesheck2019/MediafireSDK/releases
NuGet: NuGet

Features

  • Assemblies for .NET 4.5.2 and .NET Standard 2.0 and .NET Core 2.1
  • Just one external reference (Newtonsoft.Json)
  • Easy installation using NuGet
  • Upload/Download tracking support
  • Proxy Support
  • Upload/Download cancellation support

List of functions:

  • ChangeFilePrivacy
  • ChangeFolderPrivacy
  • CheckIfFileExist
  • CopyFile
  • CopyFolder
  • CopyMultipleFiles
  • CopyMultipleFolders
  • CreateNewFolder
  • DeleteFile
  • DeleteFolder
  • DeleteMultipleFiles
  • DeleteMultipleFolders
  • DownloadFile
  • DownloadFileAsStream
  • DownloadMultipleFilesAsZip_premium
  • EmptyRecycleBin
  • FileMetadata
  • FolderMetadata
  • Get10MinToken
  • Get2YearToken
  • GetActionToken
  • GetFileLinks
  • GetFilesDownloadUrlAsZip
  • GetMultipleFilesLinks
  • ListFolder
  • ListRecycleBin
  • ListRoot
  • MoveFile
  • MoveFolder
  • MoveMultipleFiles
  • MoveMultipleFolders
  • MultipleFilesMetadata
  • OneTimeUseUrl
  • RenameFile
  • RenameFolder
  • RenewToken
  • RenewToken
  • ReplaceFile
  • ResizeDirectImageUrl
  • RevokeActionToken
  • RootMetadata
  • SearchFolder
  • SearchRoot
  • SpaceQuota
  • TrashFile
  • TrashFolder
  • TrashMultipleFiles
  • TrashMultipleFolders
  • UpdateFile
  • UploadLocalFile
  • UploadRemoteFile
  • UserInfo
  • UserSettings

CodeMap codemap

Code simple:

    Async Sub Get_10Min_Token()
        Dim tkn = Await MediafireSDK.GetToken.Get10MinToken("user", "pass")
        DataGridView1.Rows.Add(tkn.response.session_token)
    End Sub

    Sub SetClient()
        Dim MyClient As MediafireSDK.IClient = New MediafireSDK.MClient("tkn.response.session_token", "user", "pass")
    End Sub

    Sub SetClientWithOptions()
        Dim Optians As New MediafireSDK.ConnectionSettings With {.CloseConnection = True, .TimeOut = TimeSpan.FromMinutes(30), .Proxy = New MediafireSDK.ProxyConfig With {.ProxyIP = "172.0.0.0", .ProxyPort = 80, .ProxyUsername = "myname", .ProxyPassword = "myPass", .SetProxy = True}}
        Dim MyClient As MediafireSDK.IClient = New MediafireSDK.MClient("tkn.response.session_token", "user", "pass", Optians)
    End Sub

    Async Sub ListFilesFolders()
        Dim Fileresult = Await MyClient.Data.Folder.List("folder Id/root = null", FilesFoldersEnum.files, FilesFilterEnum.all, Nothing, FilesOrderByEnum.name, Nothing, SortEnum.asc, 600, 1)
        For Each vid In Fileresult.response.folder_content.FilesList
            DataGridView1.Rows.Add(vid.FileID, vid.name, vid.size, vid.views)
        Next
        Dim Folderresult = Await MyClient.Data.Folder.List("folder Id/root = null", FilesFoldersEnum.folders, Nothing, FoldersFilterEnum.public, Nothing, FoldersOrderByEnum.name, SortEnum.asc, 600, 1)
        For Each vid In Folderresult.response.folder_content.FilesList
            DataGridView1.Rows.Add(vid.FileID, vid.name, vid.size, vid.views)
        Next
    End Sub

    Async Sub GetFileMetadata()
        Dim result = Await MyClient.Data.File.Metadata("file Id")
        DataGridView1.Rows.Add(result.response.file_info.name, result.response.file_info.size, result.response.file_info.FileID, result.response.file_info.filetype)
    End Sub

    Async Sub DeleteAFile()
        Dim result = Await MyClient.Data.File.Delete("file Id")
        DataGridView1.Rows.Add(result)
    End Sub

    Async Sub Upload_Local_WithProgressTracking()
        Dim UploadCancellationToken As New Threading.CancellationTokenSource()
        Dim _ReportCls As New Progress(Of MediafireSDK.ReportStatus)(Sub(ReportClass As MediafireSDK.ReportStatus)
                                                                         Label1.Text = String.Format("{0}/{1}", (ReportClass.BytesTransferred), (ReportClass.TotalBytes))
                                                                         ProgressBar1.Value = CInt(ReportClass.ProgressPercentage)
                                                                         Label2.Text = CStr(ReportClass.TextStatus)
                                                                     End Sub)
        Dim RSLT = Await MyClient.Data.File.Upload("J:\DB\myvideo.mp4", UploadTypes.FilePath, "folder id", "myvideo.mp4", IfAlreadyExist.keep, _ReportCls, UploadCancellationToken.Token)
    End Sub

    Async Sub DownloadFileLocateInPublicBucket_WithProgressTracking()
        Dim DownloadCancellationToken As New Threading.CancellationTokenSource()
        Dim _ReportCls As New Progress(Of MediafireSDK.ReportStatus)(Sub(ReportClass As MediafireSDK.ReportStatus)
                                                                         Label1.Text = String.Format("{0}/{1}", (ReportClass.BytesTransferred), (ReportClass.TotalBytes))
                                                                         ProgressBar1.Value = CInt(ReportClass.ProgressPercentage)
                                                                         Label2.Text = CStr(ReportClass.TextStatus)
                                                                     End Sub)
        Await MyClient.Data.File.Download("file url", "J:\DB\", "myvideo.mp4", _ReportCls, DownloadCancellationToken.Token)
    End Sub
Clone this wiki locally