edmiidz / google-docs-upload

Automatically exported from code.google.com/p/google-docs-upload
0 stars 0 forks source link

how to upload any file #31

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
google now allow any file format to be uploaded
can this batch tool do it

Thanks

Original issue reported on code.google.com by aboud.sa...@gmail.com on 19 Jun 2010 at 8:36

GoogleCodeExporter commented 8 years ago
It can if this is changed from this:

protected boolean isAllowedFormat(File file) {
    List<String> formats = new ArrayList<String>(Arrays.asList(SUPPORTED_FORMATS));
    return formats.contains(getFileExtension(file));
}
to this:

protected boolean isAllowedFormat(File file) {
   return true; 
}

which is now supported per 
http://docs.google.com/support/bin/answer.py?hl=en&answer=50092 

Original comment by mike.kin...@gmail.com on 22 Jun 2010 at 3:53

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
After running across this code and across this thread, I decided to have a go 
at updating the source to provide for the bulk uploading of arbitrary file 
types. After updating the line indicated above, working around the filesize 
limitations, and adding "convert=false" parameters to the file upload methods 
in DocumentList.java, I believe I ran across the ultimate explanation for the 
lack of movement on this: the gdata APIs only permit the uploading of 
non-converted files for "Google Apps Premier domains." Though I find this 
limitation exasperating and arbitrary (insofar as I am perfectly able to upload 
non-converted files manually), I do think this explains why bulk uploaders (not 
intended for exclusively "Premier" domains) are limited to supporting 
convertible file types.

Original comment by gne...@gmail.com on 18 Oct 2010 at 12:32

GoogleCodeExporter commented 8 years ago
for those readers who might need a bit more help after reading the above 
comments and who want any file format to work with Google Apps for Business 
(previously knowns as Google Apps Premier), i have added the modified lines of 
code required in DocumentList.java file

under Upload a file

return service.insert(buildUrl(URL_DEFAULT + URL_DOCLIST_FEED + 
"?convert=false")

and under Upload a file to a folder

URL url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED + "/" + folderResourceId + 
URL_FOLDERS + "?convert=false");

To get around the file size limit I made this change to the 
GoogleDocsUploader.java file

protected boolean isAllowedSize(File file) {
        Long size = SIZE_LIMITS.get(getFileType(file));
            if (size != null && file.length() <= size) {
                  return true;
            }
          return false;
}

replace with

protected boolean isAllowedSize(File file) {
   return true;
}

Once these files have been modified you will need to run javac to create the 
new class files. Once created either update the jar file (jar uf 
google-docs-upload-1.3.2.jar <file> ) or copy and replace them into the 
extracted jar directory and create yourself a new jar package (jar cmf  
META-INF/MANIFEST.MF <new_jar_file_name.jar> *)

I found it useful to extract the jar file google-docs-upload-1.3.2.jar (jar xf 
google-docs-upload-1.3.2.jar) and copy the new class files into this directory. 
The above might be some help to people who are not familiar with java.

Once done this tool worked like a charm for me - it did not convert my files 
nor skip files because they were over the size limit. This tool saved us a lot 
of work so thanks.

Original comment by *...@lemon-computing.com on 29 Nov 2010 at 11:48

GoogleCodeExporter commented 8 years ago

Original comment by anton.be...@gmail.com on 22 Dec 2010 at 2:48