Skip to content
jackkoolage edited this page Jan 31, 2020 · 11 revisions

4sharedSDK

Download:https://github.com/jackkoolage/4sharedSDK/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:

Token

  1. Login
  2. Register

Account(Mine)

  1. UserInfo
  2. UpdateUserInfo
  3. GetAvatarPicture
  4. SetAvatarPicture

Comment

  1. ListComments
  2. Create
  3. Delete
  4. Reply
  5. ReportAsSpam
  6. UnReportAsSpam

Data

  1. SearchRoot
  2. EmptyRecycleBin
  3. ListRoot
  4. RootID
  5. RecycleBinID
  6. ListRecycleBin
  7. RestoreRecycleBin
  8. GetLinkForFile

File

  1. Upload
  2. UploadLargeFile
  3. Update
  4. UpdateLargeFile
  5. Copy
  6. CopyMultiple
  7. Move
  8. MoveMultiple
  9. Trash
  10. UnTrash
  11. TrashMultiple
  12. Delete
  13. DeleteMultiple
  14. Metadata
  15. EditMetadata
  16. ChangePrivacy
  17. Rename
  18. Download
  19. DownloadLargeFile
  20. DownloadAsStream
  21. ImportToMyAccount
  22. ThumbnailUrl
  23. UnZip
  24. Exists

Folder

  1. Password
  2. SetDescription
  3. ChangePermission
  4. ChangePrivacy
  5. Search
  6. ListSubFiles
  7. ListSubFolders
  8. Create
  9. Copy
  10. CopyMultiple
  11. Move
  12. MoveMultiple
  13. UnTrash
  14. Trash
  15. Delete
  16. DeleteMultiple
  17. TrashMultiple
  18. Rename
  19. Metadata
  20. Exists
  21. ExistsInTargetFolder

User

  1. SearchFiles
  2. Metadata
  3. AvatarPicture
  4. ListFilesRelatedToFile

CodeMap:

codemap

Code simple:

    Async Function tasks() As Task
        'first login (one time only)
        Dim tokn = Await FourSharedSDK.GetToken.Login_Base64("your_email", "your_password")
        ''set proxy and connection options
        Dim con As New FourSharedSDK.ConnectionSettings With {.CloseConnection = True, .TimeOut = TimeSpan.FromMinutes(30), .Proxy = New FourSharedSDK.ProxyConfig With {.SetProxy = True, .ProxyIP = "127.0.0.1", .ProxyPort = 8888, .ProxyUsername = "user", .ProxyPassword = "pass"}}
        ''set api client
        Dim client As FourSharedSDK.IClient = New FourSharedSDK.FClient(tokn, Nothing)


        ''functions:
        'Account
        Await client.Account.GetAvatarPicture(ImageSizeEnum._72x72)
        Dim _ReportCls As New Progress(Of FourSharedSDK.ReportStatus)(Sub(ReportClass As FourSharedSDK.ReportStatus)
                                                                          Label1.Text = String.Format("{0}/{1}", (ReportClass.BytesTransferred), (ReportClass.TotalBytes))
                                                                          Label1.Text = CInt(ReportClass.ProgressPercentage)
                                                                          Label1.Text = If(CStr(ReportClass.TextStatus) Is Nothing, "Uploading...", CStr(ReportClass.TextStatus))
                                                                      End Sub)
        Await client.Account.SetAvatarPicture("c:\\pic.jpg", UploadTypes.FilePath, "pic.jpg", _ReportCls, Nothing)
        Await client.Account.UpdateUserInfo("first_name", "last_name", "pass", "email", AllowSearchEnum.disabled)
        Await client.Account.UserInfo

        ''Comments
        Await client.Comments.Create("file_id", "this is comment")
        Await client.Comments.Delete("file_id", "comment_id")
        Await client.Comments.ListComments("file_id", 50, 0)
        Await client.Comments.Reply("file_id", "comment_id", "this is replay to an comment")
        Await client.Comments.ReportAsSpam("comment_id")
        Await client.Comments.UnReportAsSpam("comment_id")

        ''Data
        Await client.Data.EmptyRecycleBin
        Await client.Data.GetLinkForFile
        Await client.Data.ListRecycleBin(Nothing, 50, 0)
        Await client.Data.ListRoot("root_id", 50, 0)
        Await client.Data.RecycleBinID("root_id")
        Await client.Data.RestoreRecycleBin(Nothing)
        Await client.Data.RootID()
        Await client.Data.SearchRoot("emy", FileTypeEnum.Music, 50, 0)

        ''Files
        Await client.Files.ChangePrivacy("", True)
        Await client.Files.Copy("file_id", "folder_id", "newName")
        Await client.Files.CopyMultiple(New List(Of String) From {{"file_id"}, {"file_id"}}, "folder_id")
        Await client.Files.Delete("file_id")
        Await client.Files.DeleteMultiple(New List(Of String) From {{"file_id"}, {"file_id"}})
        Await client.Files.Download("/My 4shared/oppo/bouncy1.8.5.zip", "c:\\", _ReportCls, Nothing)
        Await client.Files.DownloadAsStream("/My 4shared/oppo/bouncy1.8.5.zip", _ReportCls, Nothing)
        Await client.Files.DownloadLargeFile("/My 4shared/oppo/bouncy1.8.5.zip", "c:\\", _ReportCls, Nothing)
        Await client.Files.EditMetadata("file_id", "this is file", "sdk,api,cloud")
        Await client.Files.Exists("file_id")
        Await client.Files.ImportToMyAccount("file_id", "folder_id")
        Await client.Files.Metadata("file_id", AddFieldsEnum.ImageMetainfo)
        Await client.Files.Move("file_id", "folder_id")
        Await client.Files.MoveMultiple(New List(Of String) From {{"file_id"}, {"file_id"}}, "folder_id")
        Await client.Files.Rename("file_id", "newName")
        Await client.Files.ThumbnailUrl("file_id", ImageSizeEnum._320x240)
        Await client.Files.Trash("file_id")
        Await client.Files.TrashMultiple(New List(Of String) From {{"file_id"}, {"file_id"}})
        Await client.Files.UnTrash("file_id")
        Await client.Files.UnZip("file_id")
        Await client.Files.Update("c:\\fle.mp4", UploadTypes.FilePath, "file_id", "folder_id", "fle.mp4", _ReportCls, Nothing)
        Await client.Files.UpdateLargeFile("c:\\fle.mp4", UploadTypes.FilePath, "file_id", "folder_id", "fle.mp4", 12345, _ReportCls, Nothing)
        Await client.Files.Upload("c:\\fle.mp4", UploadTypes.FilePath, "folder_id", "fle.mp4", _ReportCls, Nothing)
        Await client.Files.UploadLargeFile("c:\\fle.mp4", UploadTypes.FilePath, "folder_id", "fle.mp4", 123456, _ReportCls, Nothing)

        ''Folders
        Await client.Folders.ChangePermission("folder_id", FolderPermissionsEnum.read)
        Await client.Folders.ChangePrivacy("", PrivacyEnum.private)
        Await client.Folders.Copy("folder_id", "folder_id", Nothing)
        Await client.Folders.CopyMultiple(New List(Of String) From {{"folder_id"}, {"folder_id"}}, "folder_id")
        Await client.Folders.Create("folder_id", "new folder", "music dir")
        Await client.Folders.Delete("folder_id")
        Await client.Folders.DeleteMultiple(New List(Of String) From {{"folder_id"}, {"folder_id"}})
        Await client.Folders.Exists("folder_id")
        Await client.Folders.ExistsInTargetFolder("work folder", "folder_id")
        Await client.Folders.ListSubFiles("folder_id", FileTypeEnum.Video, AddFieldsEnum.id3, 50, 0)
        Await client.Folders.ListSubFolders("folder_id", 50, 0)
        Await client.Folders.Metadata("folder_id")
        Await client.Folders.Move("folder_id", "folder_id", Nothing)
        Await client.Folders.MoveMultiple(New List(Of String) From {{"folder_id"}, {"folder_id"}}, "folder_id")
        Await client.Folders.Password("folder_id", "1234")
        Await client.Folders.Rename("folder_id", "new name")
        Await client.Folders.Search("folder_id", "emy", FileTypeEnum.Video, 50, 0)
        Await client.Folders.SetDescription("folder_id", "this is des")
        Await client.Folders.Trash("folder_id")
        Await client.Folders.TrashMultiple(New List(Of String) From {{"folder_id"}, {"folder_id"}})
        Await client.Folders.UnTrash("folder_id")

        ''Users
        Await client.Users.AvatarPicture("user_id", ImageSizeEnum._320x240)
        Await client.Users.ListFilesRelatedToFile("file_id", 50, 0)
        Await client.Users.Metadata("user_id")
        Await client.Users.SearchFiles("emy", FilesFilterEnum.all, FilesTypeEnum.asf, 5000, 60000, SortByEnum.name, OrderByEnum.asc, 50, 0)
    End Function
Clone this wiki locally