Probléme de fichier binaire dans google drive

bonjour, pourquoi quand je télécharge une image dans google drive , j'ai un fichier binaire au lieu d'avoir un fichier image ?

Ensure that you are uploading your images correctly:

Check your blocks and your script are working correctly

oui j'ai regardé mais je n'arrive pas a savoir où se trouve l'erreur !
j'ai vérifié le bloc web (il y a 2 images et la première "modifphoto21" n'a pas de problème)

le bloc du bouton qui envoie l'image dans google drive
Capture5

j'ai même débogué pour voir (et ça à l'air normale)

le secteur d'image
Capture7

Le script (il a l'air correct) :

function doPost(e) {
var ss = SpreadsheetApp.openById('1BSUDHn08h6YlrtgfeoQEVhjdvNp3rGPxZiTVq9r-bSY');
var sh = ss.getSheetByName("Sheet2");

var data = Utilities.base64Decode(e.parameters.data);
var blob = Utilities.newBlob(data, e.parameters.mimetype, e.parameters.filename);
var fileID = DriveApp.getFolderById('1BWoRLu1haTUObzW88d8hL54xcAgdDUzt').createFile(blob).getId();

var rowData = ;
var rg = sh.getDataRange().getValues();
var nomExist = '';

for (var row=1 ; row<rg.length ; ++row){
if (e.parameters.nom[0] === rg[row][0]){
sh.getRange(row+1,9 + parseInt(e.parameter.imgno)).setValue(e.parameters.filename[0]);
sh.getRange(row+1,7 + parseInt(e.parameter.imgno)).setValue(fileID);
nomExist = e.parameters.nom;
}
}
if (nomExist == '') {
rowData.push(e.parameters.nom[0]);
rowData.push('other');
rowData.push(e.parameters.filename[0]);
rowData.push(fileID);
sh.appendRow(rowData);
}
return ContentService.createTextOutput('Image: ' + e.parameters.filename + ' with ID: ' + fileID + ' successfully uploaded to Google Drive');
}

et j'ai aussi l'ID de l'image dans googlesheet .

image

  1. You appear to be setting the mimetype twice ?

  2. You appear to be setting the data parameter to a label ? This should be the base64 string of the image.

  3. You do not set a parameter for this last entry, but why would you be setting the image.picture as a parameter (this would either be a file path or a binary file....)

euh , mais comment vous définiriez le bloc alors , parce que j'ai un autre bloc bouton qui est pareil et il n'envoie pas le fichier binaire ?

I cannot explain it.

You are using blocks to create a postText that does not follow my guide, which I know works.

I also note that you are not setting a filename, which gives all your image file the default Untitled filename.

All I can suggest is that you do some debugging of your blocks using Do It, this will help you to find the problem.

c'est bon j'y suis arrivé . En regardant bien tranquillement votre guide et le mien, je me suis rendu compte que j'envoyais 2 fichiers dans la même étiquette. Merci beaucoup

If you are storing a base64 string of an image to a label, it may slow your app or even crash it. Store it to a variable instead.

ok , oui effectivement ça ralenti et parfois ça plante, merci beaucoup pour l'information.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.