MCPcopy Create free account
hub / github.com/apache/cloudberry / uploadS3

Function uploadS3

gpcontrib/gpcloud/bin/gpcheckcloud/gpcheckcloud.cpp:231–279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

229}
230
231static bool uploadS3(const char *urlWithOptions, const char *fileToUpload) {
232 if (!urlWithOptions) {
233 return false;
234 }
235
236 size_t data_len = BUF_SIZE;
237 char data_buf[BUF_SIZE];
238 size_t read_len = 0;
239 bool ret = true;
240
241 thread_setup();
242
243 GPWriter *writer = writer_init(urlWithOptions);
244 if (!writer) {
245 return false;
246 }
247
248 FILE *fd = fopen(fileToUpload, "r");
249 if (fd == NULL) {
250 fprintf(stderr, "File does not exist\n");
251 ret = false;
252 } else {
253 do {
254 read_len = fread(data_buf, 1, data_len, fd);
255
256 if (read_len == 0) {
257 break;
258 }
259
260 if (!writer_transfer_data(writer, data_buf, (int)read_len)) {
261 fprintf(stderr, "Failed to write data to Amazon S3\n");
262 ret = false;
263 break;
264 }
265 } while (read_len == data_len && !S3QueryIsAbortInProgress());
266
267 if (ferror(fd)) {
268 ret = false;
269 }
270
271 fclose(fd);
272 }
273
274 writer_cleanup(&writer);
275
276 thread_cleanup();
277
278 return ret;
279}
280
281int main(int argc, char *argv[]) {
282 bool ret = true;

Callers 1

mainFunction · 0.85

Calls 6

thread_setupFunction · 0.85
writer_initFunction · 0.85
writer_transfer_dataFunction · 0.85
writer_cleanupFunction · 0.85
thread_cleanupFunction · 0.85
S3QueryIsAbortInProgressFunction · 0.70

Tested by

no test coverage detected