Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Media upload not working anymore with big files since updating modules #1038

Closed
CyberT33N opened this issue Mar 4, 2018 · 3 comments
Closed
Assignees
Labels
needs more info This issue needs more information from the customer to proceed.

Comments

@CyberT33N
Copy link

CyberT33N commented Mar 4, 2018

Hey since google drive was changing their library I´am not able to upload anymore files bigger than 5MB with the basic upload drive.files.create. The docs told me that I have to choose resumable uploads instead. But google drive didn´t provide any sample code and aswell I can´t find anything on google.

Maybe it´s important to know that I can upload files smaller than 5MB with the drive.files.create

So there is no problem with the auth.

https://developers.google.com/drive/v3/web/resumable-upload

I wrote this POST request(Also not working with PUT):

var fs = require('fs')
var request = require('request')
var file = 'C:\\test\\sample.container'
var uploadUrl = 'https://www.googleapis.com/drive/v3/files?uploadType=resumable'
var stats = fs.statSync(file)
var fileSizeInBytes = stats["size"]

fs.readFile(file, function read(e, f) {
  if (e) {
    console.log(e)
    return;
  }
  request.post({
    url: uploadUrl,
    headers: {
      'Authorization': 'xxxxxxxxxxxxxxxxxxxxxxx',
      'Content-Length': fileSizeInBytes,
      'Content-Type': 'application/octet-stream'
    },
    body: f,
  }, function (e, r, b) {
    if (e) {
      console.log(e)
      return;
    }
    console.log(`Response: ${ JSON.stringify(r)} Body: ${b}`)
  });
}); 

but I get as body result:

    <HTML>
    <HEAD>
    <TITLE>Request Entity Too Large</TITLE>
    </HEAD>
    <BODY BGCOLOR="#FFFFFF" TEXT="#000000">
    <H1>Request Entity Too Large</H1>
    <H2>Error 413</H2>
    </BODY>
    </HTML>

If I would use as request url instead:
https://www.googleapis.com/upload/drive/v3/files?uploadType=resumable

I get aswell an similiar message as body result:
Request is too large.

So anybody has a working code for uploading files with the resumable upload or maybe again with the basic upload? Or is there another way for uploading big files? I´am open for alternatives! Thank you

@JustinBeckwith JustinBeckwith self-assigned this Mar 5, 2018
@JustinBeckwith JustinBeckwith added the needs more info This issue needs more information from the customer to proceed. label Mar 5, 2018
@JustinBeckwith
Copy link
Contributor

Greetings! I think we may have fixed this here:
6f684c2

Can you try things with v27 of the library and let me know if you're still having problems?

@CyberT33N
Copy link
Author

Awesome! with v27.0.0 it is working again with the basic upload aka drive.files.create

The POST request is still giving me the error message that my request is too big.. Maybe my code is wrong. You have a working sample code for single or chunked POST request?

Also since the update of your library my upload progess tracking is not working anymore. The code below was working a year ago and now I get a error that req is undefined. How can you track the upload progress with your latest library?

`/**/

    var fileMetadata = {
        'name': together,
        parents: [ foldername_folderid ]

    }

    var media = {
        mimeType: 'application/octet-stream',
        body: fs.createReadStream('C:/test/sample.container')
    }

    var req = drive.files.create({
        resource: fileMetadata,
        media: media,
        auth: auth,
        fields: 'id'
    }, function(e, file) {
        if (e) {
          console.log('error: ' + e)
          return;
        } 
        
         console.log('DONE')
         clearInterval(object.q)
        
    });





getSize('C:/test/sample.container', function(e, size) {
  if (e) {
   console.log('error: ' + e)
   return;
  } 


 object.q = setInterval(function () {
   chalkAnimation.neon( 'Google Drive - We uploaded ' + pretty(req.req.connection.bytesWritten) + ' from ' + pretty(size), 1 );
 }, 1600) 



});

`

@sostenesapollo
Copy link

This is working today yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more info This issue needs more information from the customer to proceed.
Projects
None yet
Development

No branches or pull requests

3 participants