Files Upload to google drive stops working

@TIMAI2, one thing, is the method provided from your app applicable to image component?

Like setting image component from a selected image rom an imagepicker.

The camera component have the image variable in it but not the list picker.

As you can see, the first example uses the camera component to return the when PictureTaken event. The second example (thumbnails) does not create a file, it returns the base64 directly.

If you want to use the image picker (using the first example as a base), you could probably replace the camera blocks with the imagepicker blocks. On Android 13, camera images are saved to the ASD, therefore not available to the image picker, unless you copy them to shared storage.

As the camera have an image variable that the image picker do not have.

The image variable is used by the KIO4 extension.

[Still using the first example]

If DefaultFileScope is set to "App", camera images are saved to the ASD on all Android version. If DefaultFileScope is set to "Legacy" images are saved in /My Documents/Pictues/ but only up to Android 10. On Android 11+ it is of course no longer possible to write / save in an arbitrary folder of the external storage.

Note: Unfortunately, the Camera component does not provide for saving to one of the shared folders if DefaultFileScope = Shared or Legacy is set.

Not so:

image

MIT did not put it in the afterPicking event....

1 Like

Hello @TIMAI2 its work fine, thank you.

One last thing before closing this matter.

To send the data we use the POST method.

I tried to do it with DoGet, based on one of my precious question Secure connection to google sheet and app script - #8 by TIMAI2
where I used a key as parameter to append the data.

Is it possible to do it with pictures too?

I tried but I got errors.

Why do you "need" to use doGet(e) ? doPost(e) works just fine, and can probably more easily cope with large base64Strings

1 Like

Ok acknoledge thanks

Image Upload discrepancies

Hello all, trust you are doing well.

I'm current working on project to upload picture to google drive.

I was helped by @TIMAI2 who helped me in uploading the picture to the drive.

The app take 2 pictures from the image picker and set the Image component with the selected images.

Now I am facing an issue where I can upload the picture but is wrongly uploaded.[Not the image].

Here is my blocks :

image

image

The code use:

function doPost(e) {
    
  var data = Utilities.base64Decode(e.parameters.data);
  
  var name =  e.parameters.name ;

  var filename =  name + ", Orders of the " + Utilities.formatDate(new Date(), "GMT+8", "EE dd-MM-yyyy HH:mm:ss");

  var blob = Utilities.newBlob(data, e.parameters.mimetype, filename);

  DriveApp.getFolderById("1vuPyhV7oHje0T-hLsuWbH6VGauUn8OoV").createFile(blob);

  return ContentService.createTextOutput("Picture of " + name + " uploaded");



}

The error i got from the response :

The uploaded images :

1 out of 2

2 out of 2

To begin with, remove the comma where you make the filename, replace with hyphen or underscore. It would be better to have no spaces in your filename, at all, so use underscores if you need separation.

Hello @TIMAI2 issue perist.

When I modified your aia, I got and issue reponse but it worked, the picture was uploaded with the filename.

In my app I replicated the same blocks but got the issue mentionned.

I have provided two working solutions, you need to follow these correctly and apply to your particular requirements.

That what I did. :confused:

I followed the blocks and did not miss the important block.

But you have indicated that you modified it!

Yes I modified it only in term of image capture.
I change only the camera block and replace the variable image fom the camera block to the image picker.

The other block are only interm of layout.

Provide an aia project, you can replace any specific values with identifiable variables. Also provide your script. I will see what I can do with it.

Hello my apologies I was sick, I will upload the aia asap.

Hello, trust you are doing well.

You will find attached the aia. Still same issue on my side :confused:

FTEST.aia (26.1 KB)

and your script.....

function doPost(e) {
    
  var data = Utilities.base64Decode(e.parameters.data);
  
  var name =  e.parameters.name ;

  var filename =  name + ", Orders of the " + Utilities.formatDate(new Date(), "GMT+4", "EE dd-MM-yyyy HH:mm:ss");

  var blob = Utilities.newBlob(data, e.parameters.mimetype, filename);

  DriveApp.getFolderById("xxxxxxxxxxxxxxxxxxxxxx").createFile(blob);

  return ContentService.createTextOutput("Picture of " + name + " uploaded");



}