我們如何在下載/上傳 dropbbox 方法中獲取文件 mime-type/content-type? (How can we get files mime-type/content-type in download/upload dropbbox methods?)


問題描述

我們如何在下載/上傳 dropbbox 方法中獲取文件 mime‑type/content‑type? (How can we get files mime‑type/content‑type in download/upload dropbbox methods?)

這裡我們正在嘗試識別上傳/下載的文件mime‑type/content‑type

我們正在使用以下方法。下載:

dropBoxClient.Files.DownloadAsync(filePath)

上傳:

dropBoxClient.Files.UploadAsync(filePath)

提前致謝。


參考解法

方法 1:

    private  string GetMimeType(string fileName)
    {
        string mimeType = "application/unknown";
        string ext = System.IO.Path.GetExtension(fileName).ToLower();
        Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(ext);
        if (regKey != null && regKey.GetValue("Content Type") != null)  
        mimeType = regKey.GetValue("Content Type").ToString();
        System.Diagnostics.Debug.WriteLine(mimeType);  
        return mimeType;
    }

</blockquote>

(by Jeet Bhattzia khan)

參考文件

  1. How can we get files mime‑type/content‑type in download/upload dropbbox methods? (CC BY‑SA 2.5/3.0/4.0)

#dropbox #asp.net-web-api #dropbox-api #C#






相關問題

獲取 Dropbox 共享鏈接的文件列表 (Get list of files for dropbox shared link)

將文件上傳到保管箱時,方法出錯 (while uploading a file to dropbox getting an error with method)

Dropbox Api putFile php 發送文件失敗 (Dropbox Api putFile php fail send file)

Tiếp tục quá trình tải lên trong IOS nền (Continue uploading process in background IOS)

API Dropbox: phát hiện cập nhật tệp và nhận URL đến tệp? (Dropbox API: detect file updates, and get a URL to a file?)

Mac OS X 文件的 st_flags(用戶定義的標誌)是什麼? (What are st_flags (user defined flags) for a file Mac OS X?)

Dropbox如何監控? (How does dropbox monitoring?)

如何在 Dropbox 中使用 Bazaar? (How to use Bazaar with Dropbox?)

在 Python 中使用 OAuth2 連接到保管箱時出錯 (Error using OAuth2 to connect to dropbox in Python)

從樹莓派自動上傳到保管箱? (automatic upload on dropbox from raspberry pi?)

識別 macOS 上的託管文件夾 (Identify managed folders on macOS)

我們如何在下載/上傳 dropbbox 方法中獲取文件 mime-type/content-type? (How can we get files mime-type/content-type in download/upload dropbbox methods?)







留言討論