2

While implementing file upload using Microsoft Graph API I faced the issue that once I upload file I don't get MIME type of it. I can't send it via API as well as it's not determined automatically. I use resumable upload API:

https://dev.onedrive.com/items/upload_large_files.htm

I was thinking about determining it from the name(extension part) on my side, when I get the name of the file, but I hope there is a better way to do this with OneDrive Microsoft Graph API.

Marc LaFleur
  • 31,987
  • 4
  • 37
  • 63
dvelopp
  • 4,095
  • 3
  • 31
  • 57
  • Are you making calls to business accounts via MS Graph? – Brad Aug 21 '17 at 16:59
  • Can I ask you about the mimeType and file size of file you uploaded? – Tanaike Aug 21 '17 at 22:57
  • @Brad I'm afraid we haven't bought that yet. – dvelopp Aug 22 '17 at 09:06
  • @Tanaike for now it's mp4 file that has size over 30 MB – dvelopp Aug 22 '17 at 09:07
  • I tried to upload mp4 with over 30MB. I confirmed that in my environment, mp4 movie with the size of 50MB could be uploaded and the mimeType of ``video/mp4`` was automatically given. The sample script I used is https://stackoverflow.com/questions/45684079/onedrive-api-node-js-can%C2%B4t-use-createuploadsession-content-range-error/45684427#45684427 I hope this information will be helpful for you. – Tanaike Aug 22 '17 at 23:24
  • There is a difference between Business and Consumer on this front which is why I was looking for some clarification - see https://github.com/OneDrive/onedrive-api-docs/issues/643 for some details – Brad Aug 23 '17 at 19:07
  • @Tanaike where did you find the mime type? https://dev.onedrive.com/resources/item.htm resource just doesn't have it – dvelopp Aug 29 '17 at 08:38
  • In file facet I have something like this: "file": { "hashes": { "quickXorHash": "nzVCFwCojs+ZfdrTaYAedROm1QY=" } }, – dvelopp Aug 29 '17 at 08:41
  • There is no parameter for including mimeType. By uploading the file, the mimeType was given automatically. My account is not for Business. – Tanaike Aug 29 '17 at 08:42
  • File section has a mime type in your case or you get it somewhere else ? – dvelopp Aug 29 '17 at 09:05
  • When it completed the upload of the file, ``mimeType`` is included in the response. Also I use the resumable upload method. When I uploaded a zip file with the filename of "sample.png", ``mimeType`` of the uploaded response was ``image/png``. So it is found that OneDrive defines ``mimeType`` by the extension of the file. In this case, ``the resumable upload`` is used. For example, when you use [the simple upload](https://dev.onedrive.com/items/upload_put.htm), how will mimeType be? And if you reply me, can you add ``@Tanaike``? When ``@Tanaike`` is not added, I cannot notice to your reply. – Tanaike Aug 30 '17 at 00:10

0 Answers0