Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int
- deltacloud_upload_blob(struct deltacloud_api csp, char *bucket_id, char *blob_id, char *file_path)
- {
- struct deltacloud_bucket bucket;
- if(deltacloud_get_bucket_by_id(&csp, bucket_id, &bucket)< 0)
- {
- fprintf(stderr, "UPLOAD: Failed to obtain bucket %s: %s.\n", bucket_id, deltacloud_get_last_error_string());
- return -1;
- }
- struct deltacloud_bucket_blob blob;
- if(deltacloud_bucket_get_blob_by_id(&csp, &bucket, blob_id, &blob)>= 0)
- {
- deltacloud_bucket_delete_blob(&csp, &blob);
- deltacloud_free_bucket_blob(&blob);
- }
- int64_t file_in_cache;
- if((file_in_cache= open(file_path, O_RDONLY))< 0)
- {
- fprintf(stderr, "UPLOAD: Failed to open file %s from cache.\n", file_path);
- return -1;
- }
- close(file_in_cache);
- struct deltacloud_create_parameter params;
- if(deltacloud_bucket_create_blob_from_file(&csp, &bucket, blob_id, file_path, ¶ms, 0)< 0)
- {
- fprintf(stderr, "UPLOAD: Failed to upload file %s: %s.\n", blob_id, deltacloud_get_last_error_string());
- return -1;
- }
- deltacloud_free_bucket(&bucket);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment