I have to upload some large files and folders to Google Drive. In order to make sure data is uploaded perfectly, I need to check their md5sums. Is there any other way to check uploaded files are completely uploaded?
When you upload the file the file resource is returned to you. The file resource contains a md5Checksum you should just be able to compare it with the one you have.
Try a file.list and you can see them all.
let files = Drive.Files.list();
for (item of files.items) {
Logger.log(item['md5Checksum']);
}
I have a file hosted on AWS Linux AMI. The link is http://54.179.188.146/a/a.docx I can visit the link and download the file.
I am trying to use Microsoft Online Doc Viewer to view the Word File online at this link https://view.officeapps.live.com/op/view.aspx?src=http://54.179.188.146/a/a.docx but it returns a page stating "An error occurred We're sorry, but for some reason we can't open this for you."
I had chmod the file to 775 but it still cannot view.
I had uploaded to another server and it is working. May I know what is wrong? Is it a server configuartion issue? Please advise.
Thanks.
This is Old but giving some more pointers to the new visitors , i am posting the consolidated answer for the root cause of the "We’re sorry, but for some reason we can’t open this for you" error in https://view.officeapps.live.com/op/view.aspx?src=
If you see the error, "We’re sorry, but for some reason we can’t open this for you," it means the document could not be found or could not be displayed. Likely reasons include:
There’s no document to be found at the URL you provided. Make sure
you provide the correct URL.
The document is too large. Word and PowerPoint documents must be less
than 10 megabytes; Excel must be less than five megabytes.
The document was not saved in a format that is supported for opening
in a web browser. Try saving your document in one of the following
formats:
Word: docx, docm, dotm, dotx
Excel: xlsx, xlsb, xls, xlsm
PowerPoint: pptx, ppsx, ppt, pps, pptm, potm, ppam, potx, ppsm
You need to sign in or provide a password to open the document. Make
the document publically available to view.
The document’s file name contains invalid characters. Try encoding
the file name when you type the document’s URL, or rename the file to
use only letters and numbers. For example, to encode a URL that
includes an ampersand (i.e. &), you would type %26 for the ampersand
character. For more information about URL encoding, also known as
percent encoding.
more info can be found here
The value after "src=" should be URL-encoded. See details on MS Page
You should checked all reasons from here
There’s no document to be found at the URL you provided. Make sure you provide the correct URL.
Try to open file from browser.
Make sure you don't try to send on preview service path of the file from your local host. To which, obviously, there is no access from the Internet.
Path to file must be http:// or https://
If path to your file start with https:// make sure your site have necessary secure certificate.
Domain name matters.
Will not be open in preview service
http://185.231.70.200/vacuumcleanerprocedure.doc
Will be open in preview service
http://domainname.com/vacuumcleanerprocedure.doc
The document is too large. Word and PowerPoint documents must be less than 10 megabytes; Excel must be less than five megabytes.
Try different files with different Microsoft file types.
The document was not saved in a format that is supported for opening in a web browser. Try saving your document in one of the following
formats: Word: docx, dotx Excel: xlsx, xlsb, xls, xlsm PowerPoint:
pptx, ppsx, ppt, pps, potx, ppsm
Try different files with different Microsoft file types.
You need to sign in or provide a password to open the document. Make the document publicly available to view.
File permission and folders mode should be 775.
Check if in .htaccess file of your apache server there are allow access to ms-office files.
Check if your file available from internet. Try to open file from browser. If you see “You don't have permission to access filename on this server” see answer here
The document’s file name contains invalid characters. Try encoding the file name when you type the document’s URL, or rename the file to
use only letters and numbers. For example, to encode a URL that
includes an ampersand (&), you would type %26 for the ampersand
character. For more information about URL encoding, also known as
percent encoding, see Percent-encoding on Wikipedia.
The value after "src=" should be URL-encoded. When you place the link on the preview service, it already encodes it for preview. Additionally, I may encode the link here, but the result will be the same.
I get files from google drive(Using Java)
Everything works! BUT, when I see pdf documents mime type
file.getMimeType()
it is something like that: application/vnd.google-apps.document
it is not application/pdf
Question 1: Why is my pdfs at google drive with mime type application/vnd.google-apps.document
Question 2:
I need to filter my document, in order to get only PDF documents:
but this does not works! Googel thinks that my PDF is "vnd.google-apps.document"!
String mime ="application/pdf"; //works when I set vnd.google-apps.document
String query="'"+id+"'" +" in parents and trashed=false and and mimeType="+mime;
FileList files = service.files().list().setQ(query).execute();
I've been reading a number of comments recently that Drive PDFs have become editable. So my guess is that you uploaded your PDFs with convert=true, and so Drive has converted them to docs. To prevent this, make sure that convert=false.
I am trying to make a "Save as" to google drive functionality for my web app. The user is shown the Google Picker and chooses a file to save over. At this point the application is updating the content of the file successfully, but it doesn't change the mimeType of the file being overwritten.
The api reference specifies the following about the mimeType metadata:
"The MIME type of the file. This is only mutable on update when uploading new content [this is the case]. This field can be left blank, and the mimetype will be determined from the uploaded content's MIME type."
I am leaving it blank. In fact, I am doing a simple upload to PUT https://www.googleapis.com/upload/drive/v2/files/{fileId}. And the http request has the Content-Type header set to the mimeType of the file being uploaded. In this case (if this helps) is "application/vnd.ms-project". I also tried adding the uploadType=media parameter to the url, with no success.
I also tried making a multipart update using the Api playground. Sent the metadata content empty {} and the error message was "Unsupported content with type: application/vnd.ms-project". Funny it is unsuported because I did manage to create a new file with the same mimeType, with no problem.
What to do? Any sugestions?
You can't replace an existing native Docs file with a regular blob. The only way to update a docs file with a blob is switching on the Docs conversion which is not possible for a Microsoft Project file.
I've loaded some files to Google Drive, but mistakenly assigned an incorrect mimeType to some of the files. I now want to update the mimeType to be the correct value.
I have the following Python code, which successfully updates the description associated with the file, but the mimeType always retains its original value.
file = service.files().get(fileId=GoogleFileId).execute()
file['mimeType'] = 'application/msword'
file['description'] = 'test description'
updated_file = service.files().update(fileId=file['id'], body=file, updateViewedDate=False).execute()
Can anyone spot what I'm missing?
Dave
Yes, you'll have to update the file content itself. The mimeType is calculated from the file that got uploaded. Do it by passing a media_body, etc that you used to create the file.
It's a nuisance to do, sorry. But if you are scripting it, it should cause you too much pain for "some files".